Showing posts with label Cocoa Touch. Show all posts
Showing posts with label Cocoa Touch. Show all posts

Thursday, June 14, 2012

Add Views to UIAlertView


1. Create UIAlertView with buttons using UIAlertView initWithTitle methods with buttons.
2. create the views wich you wish and add it to AlertView using addSubView: methods.
3. use below delegate method to organize your views.
     - (void)willPresentAlertView:(UIAlertView *)alertView

// create alertView
-(void)configureAlert{
     alertView = [[UIAlertView alloc] initWithTitle:@"Tittle" message:@"message" delegate:self                                    
cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok",nil];
     textField = [[UITextField alloc] initWithFrame:CGRectMake(12, 86, 262, 28)];
     [textField becomeFirstResponder];
     [textField setPlaceholder:@"Password"];
     [textField setReturnKeyType:UIReturnKeyDone];  
     [textField setInputAccessoryView:customAccView1];
     [textField setFont:[UIFont fontWithName:@"Helvetica Neue" size:18]];
     [textField setContentMode:UIViewContentModeBottom];
     [textField setBackgroundColor:[UIColor whiteColor]];
     // vertical alignment of text in textField
     [textField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
     [alertView textField];
     [alertView show];
}

- (void)willPresentAlertView:(UIAlertView *)alertView { 
          [alertView setFrame:CGRectMake(17, 30, 286, 188)];
          NSArray *subviewArray = [alertView subviews];
          UILabel *label = (UILabel *)[subviewArray objectAtIndex:2];
          [label setFrame:CGRectMake(10, 46, 260, 20)];
          UIButton *buttonOk = (UIButton *)[subviewArray objectAtIndex:4];
          [buttonOk setFrame:CGRectMake(10, 130, 128, 42)];
           UIButton *buttonCancel = (UIButton *)[subviewArray objectAtIndex:3];
          [buttonCancel setFrame:CGRectMake(148, 130, 128, 42)]; 
}

   
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
     // button actions
}

Wednesday, June 13, 2012

Transparent UIWebView

To transparent the UIWebView and remove the scrolls.

webView.opaque = NO;
webView.backgroundColor = [UIColor clearColor];
for(UIView *view in webView.subviews){ 
     if ([view isKindOfClass:[UIImageView class]]) {
          // to transparent 
          [view removeFromSuperview];
     }
     if ([view isKindOfClass:[UIScrollView class]]) {
          UIScrollView *sView = (UIScrollView *)view;
          //to hide verticalScroller
          sView.showsVerticalScrollIndicator = NO;
          for (UIView* shadowView in [sView subviews]){
               //to remove shadow
               if ([shadowView isKindOfClass:[UIImageView class]]) {
                    [shadowView setHidden:YES];
               }
          }
     }
}

Friday, August 26, 2011

From NSData to CFDataRef


NSData *imageData = UIImagePNGRepresentation(originalImage);
CFDataRef cfdata = CFDataCreate(NULL, [imageData bytes], [imageData length]);