Search Results

Search found 1125 results on 45 pages for 'uiview'.

Page 32/45 | < Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >

  • How to call a method from another class that's been instantiated within the current class

    - by Pavan
    my screen has a few views like such __________________ | _____ | | | | | //viewX is a video screen | | | | | viewX | vY | | //viewY is a custom uiview i created. | |____| | //it contains a method which i would like to call that toggles |_________________| //the hidden property of this view. and when it hides, a little | | //button is replaced no the top right corner on top of viewX | viewZ | //the video layer | | |_________________| //viewZ is a view containing many square views - thumbnails. my question is, i dont know how to register for touch events so that it recognises any touch event on no matter which view the user touches the screen.. atm im handling the touch events for each view inside it. so all works well... however what im trying to do is that when the user taps anywhere else on the screen but on viewY, viewY should dissapear by calling that method in the viewY class. this viewY class is instantiated and has no xib file attached to it. the uiview is created progammatically in the viewY class. this whole class for viewY behviour is instantiated in viewX - the video view. my boss says add delegates.. although i have now clue how to do that... any help? is there anyway i can just make it really simple and be able to say REMOVE VIEW no matter which class im calling from? Also ive seen other people achieve this by using these funky arrows - ... <- etc.. although im not sure if thats what i need or how to implement such a thing. ah i think ive made my question quite complicated but i really mean it to be a simple one, and know it can be done in an easy way!

    Read the article

  • How to resize a UISwitch?

    - by mshsayem
    I have made a custom UISwitch (from this post). But the problem is, my custom texts are a bit long. Is there any way to resize the switch? [I tried setBounds, did not work] Edit: Here is the code I used: @interface CustomUISwitch : UISwitch - (void) setLeftLabelText: (NSString *) labelText; - (void) setRightLabelText: (NSString *) labelText; @end @implementation CustomUISwitch - (UIView *) slider { return [[self subviews] lastObject]; } - (UIView *) textHolder { return [[[self slider] subviews] objectAtIndex:2]; } - (UILabel *) leftLabel { return [[[self textHolder] subviews] objectAtIndex:0]; } - (UILabel *) rightLabel { return [[[self textHolder] subviews] objectAtIndex:1]; } - (void) setLeftLabelText: (NSString *) labelText { [[self leftLabel] setText:labelText]; } - (void) setRightLabelText: (NSString *) labelText { [[self rightLabel] setText:labelText]; } @end mySwitch = [[CustomUISwitch alloc] initWithFrame:CGRectZero]; //Tried these, but did not work //CGRect aFrame = mySwitch.frame; //aFrame.size.width = 200; //aFrame.size.height = 100; //mySwitch.frame = aFrame; [mySwitch setLeftLabelText: @"longValue1"]; [mySwitch setRightLabelText: @"longValue2"];

    Read the article

  • Clear button at uisearchbar not working at all

    - by kevin.ng
    I created a search bar programmatically and added to my view using the codes below: - (void)viewDidLoad { searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(xPositionForSearchBar, yPositionForSearchBar, widthForSearchBar, heightForSearchBar)]; UIView *bg = [[searchBar subviews] objectAtIndex:0]; searchBar.delegate = self; searchBar.placeholder = @"Search record"; for(UIView *view in searchBar.subviews){ if([view isKindOfClass:[UITextField class]]){ UITextField *tf = (UITextField *)view; tf.delegate = self; break; } } [bg removeFromSuperview]; [self.view addSubview: searchBar]; } The code is implemented with UISearchBarDelegate and UITextFieldDelegate. I have tried using - (void)searchBarCancelButtonClicked:(UISearchBar *)aSearchBar { NSLog(@"cancel clicked"); searchBar.text = @""; [aSearchBar resignFirstResponder]; } - (BOOL)textFieldShouldClear:(UITextField *)textField { NSLog(@"clear"); [self performSelector:@selector(searchBarCancelButtonClicked:) withObject:searchBar afterDelay: 0.1]; return YES; } and yet, the text inside the searchBar is not cleared at all when i click on the "clear button" - a circle with a "X" inside. The clear button works when I implemented it in IB. Wonder why? Kindly advice, many thanks.

    Read the article

  • Why is my view controllers view not quadratic?

    - by mystify
    I created an UIViewController subclass, and figured out that the default implementation of -loadView in UIViewController will ignore my frame size settings in a strange way. To simplify it and to make sure it's really not the fault of my code, I did a clean test with a plain instance of UIViewController directly, rather than making a subclass. The result is the same. I try to make an exactly quadratic view of 320 x 320, but the view appears like 320 x 200. iPhone OS 3.0, please check this out: UIViewController *ts = [[UIViewController alloc] initWithNibName:nil bundle:nil]; ts.view.frame = CGRectMake(0.0f, 0.0f, 320.0f, 320.0f); ts.view.backgroundColor = [UIColor cyanColor]; [self.view addSubview:ts.view]; like you can see, I do this: 1) Create a UIViewController instance 2) Set the frame of the view to a quadratic dimension of 320 x 320 3) Give it a color, so I can see it 4) Added it as a subview. Now the part, that's even more strange: When I make my own implementation of -loadView, i.e. if I put this code in there like this: - (void)loadView { UIView *v = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 320.0f, 320.0f)]; v.backgroundColor = [UIColor cyanColor]; self.view = v; [v release]; } then it looks right. Now lets think about that: In the first example, I do pretty much exactly the same, just that I let UIViewController create the view on it's own, and then take it over in order to change it's frame. Right? So why do I get this strange error? Right now I see no other way of messing around like that to correct this wrong behavior. I did not activate anything like clipsToBounds and there's no other code touching this.

    Read the article

  • Monotouch auto resizing views in iphone

    - by Tim Bassett
    I have created a view in interface builder that contains another view (content area) and a button bar at the bottom. The hierarchy is as: ->View --->mapContainer UIView ----->map MKMapView ----->OverlayView UIView --->ToolBar UIToolBar I would like the mapContainer to resize to full window when the ToolBar is hidden. I would like the map and the OverlayView to resize to the mapContainer size I have attempted the following code, but it has no effect. Please advise? public override void ViewDidLoad () { base.ViewDidLoad (); this.mapContainer.AutosizesSubviews = true ; this.View.AutosizesSubviews = true ; try { this.mapContainer.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth ; this.map.AutoresizingMask = UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleWidth ; this.map.SizeToFit(); this.mapContainer.SizeToFit(); this.map.SizeToFit(); this.View.Frame = new System.Drawing.RectangleF(0,0,this.View.Frame.Width, this.View.Frame.Height ); this.mapContainer.LayoutSubviews(); } catch(Exception ex) { Console.Write(ex.ToString()); } }

    Read the article

  • How i pass my view to nib at run time(Dynamically) in viewController class?

    - by Rajendra Bhole
    Hi, I want to create viewController class programmatically in which the view of nib file of viewController is not fixed. I have a UntitledViewController class that contains 4 UIButtons: -(IBAction)buttonPressed:(id)sender{ if((UIButton *)sender == button1){ tagNumber = button1.tag; NewViewController *newVC = [[NewViewController alloc] init]; //newVC.tagN [self.navigationController pushViewController:newVC animated:YES]; NSLog(@"Button Tag Number:- %i", tagNumber); } if((UIButton *) sender == button2){ tagNumber = button2.tag; NewViewController *newVC = [[NewViewController alloc] init]; [self.navigationController pushViewController:newVC animated:YES]; } if((UIButton *) sender == button3){ tagNumber = button3.tag; NewViewController *newVC = [[NewViewController alloc] init]; [self.navigationController pushViewController:newVC animated:YES]; } if((UIButton *) sender == button4){ int x = tagNumber; tagNumber = button4.tag; NewViewController *newVC = [[NewViewController alloc] init]; newVC.untitledVC = self; [self.navigationController pushViewController:newVC animated:YES]; } } When I will click any one of the UIButtons, I want to create a new NewViewController class with button tag property but without fixed nib file. In NewViewController's loadView event I want to fix the view of the nib of NewViewController class using UIButton's tag property (In NewViewController.xib I'm creating 4 UIViews named view1, view2, view3 and view4). -(void)loadView{ [super loadView]; CGRect frame = CGRectMake(0, 0, 320, 480); UIView *newView = [[UIView alloc] initWithFrame:frame]; newView.tag = untitledVC.tagNumber; self.view1 = newView; } Now I want that when I click button1 the NewViewController will be generated with view1 and when I click button2 the NewViewController will be generated with view2 and so on with different implementation. Thanks.

    Read the article

  • UIImageView not displaying image when property is set too early

    - by Undeadlegion
    I have an image I want to display inside a UIView. In Interface Builder, the UIView is the root and a UIImageView is its child. The view is connected to view controller's view outlet, and the image view is connected to the image view outlet: @property (nonatomic, retain) IBOutlet UIImageView *imageView; If I try to set the image property of UIImageView before it's visible, the image doesn't show up. TestView *testView = [[TestView alloc] initWithNibName:@"TestView" bundle:nil]; testview.imageView.image = [logos objectAtIndex:indexPath.row]; [self.navigationController pushViewController:testView animated:YES]; If, however, I pass the image to the controller and set the image property in view did load, the image becomes visible. TestView *testView = [[TestView alloc] initWithNibName:@"TestView" bundle:nil]; testview.image = [logos objectAtIndex:indexPath.row]; [self.navigationController pushViewController:testView animated:YES]; - (void)viewDidLoad { [super viewDidLoad]; imageView.image = image; } What is causing the image to not show up in the first scenario?

    Read the article

  • Any point in subclassing UIButton to create a custom looking button?

    - by glitch
    I want to create a set of buttons that would work and feel very much like the Metro-style tiles that are available on Windows Phones. I would like to allow the user to tap them to access their underlying functionality (open a modal or something or that sort). I'm concerned that subclassing UIButton will not get me there. I need square corners and dynamic content inside the tiles themselves. The posts I've found around SO seem to suggest that subclassing a UIButton would not be a good idea for several reasons and that I should instead use UIView. That reply is from 2010, and I have no idea if in the 2+ years since then there have been considerable changes to how one would achieve that effect. Most users these days will have iOS 5.1+ if not 6.0 soon. Let's say I do go the UIView route. Should I implement UIResponder's touch events or should I instead go the UITapGestureRecognizer route? What's the better practice in 2012? Thank you!

    Read the article

  • How to make sure an action completes before you continue

    - by HurkNburkS
    I am trying to close a UIView thats in one method from another method by calling it, The UIView closes fine but not untill after all of the processes are finished in the current method. I would like to know if there is a way to force the first thing to happen first (i.e. close UIviews) then continue the current method? This is what my method looks like - (void)selectDeselectAllPressed:(UIButton*)button { int id = button.tag; [SVProgressHUD showWithStatus:@"Updating" maskType:SVProgressHUDMaskTypeGradient]; [self displaySelected]; // removes current view so you can load hud will not be behind it if (id == 1) { [self selectAllD]; } else if (id == 2) { [self deselectAllD]; } else if (id == 3) { [self selectAllI]; } else if (id == 4) { [self deselectAllI]; } } as you can see what happens is this method is called when a button is pressed, I would like for the displaySelected method to do what it needs to do before any of the other methods are called? Currently what happes when i debug this is displaySelected method is called the thread walks through that then continues to the if statment then after the method in the if statment has finished then displaySelected changes are made... its so weird. any help would be greatly appreciated.

    Read the article

  • Monotouch UITableView image "flashing" while background requests are fetched

    - by Themos Piperakis
    I am in need of some help from you guys. I have a Monotouch UITableView which contains some web images. I have implemented a Task to fetch them asynchronously so the UI is responsive, an even added some animations to fade them in when they are fetched from the web. My problems start when the user scrolls down very fast down the UITableView, so since the cells are resusable, several background tasks are queued for images. When he is at the bottom of the list, he might see the thumbnail displaying an image for another cell, then another, then another, then another, as the tasks are completed and each image replaces the other one. I am in need of some sort of checking whether the currently displayed cell corresponds to the correct image url, but not sure how to do that. Here is the code for my TableSource class. using System; using MonoTouch.UIKit; using MonoTouch.Foundation; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using System.Diagnostics; { public class ListDelegate:UITableViewDelegate { private UINavigationController nav; public override float GetHeightForRow (UITableView tableView, NSIndexPath indexPath) { return 128; } public override void RowSelected (UITableView tableView, NSIndexPath indexPath) { DealViewController c = new DealViewController(((ListDataSource)tableView.DataSource).deals[indexPath.Row].Id,nav); nav.PushViewController(c,true); tableView.DeselectRow(indexPath,true); } public ListDelegate(UINavigationController nav) { this.nav = nav; } } public class ListDataSource:UITableViewDataSource { bool toggle=true; Dictionary<string,UIImage> images = new Dictionary<string, UIImage>(); public List<MyDeal> deals = new List<MyDeal>(); Dictionary<int,ListCellViewController> controllers = new Dictionary<int, ListCellViewController>(); public ListDataSource(List<MyDeal> deals) { this.deals = deals; } public override int RowsInSection (UITableView tableview, int section) { return deals.Count; } public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath) { UITableViewCell cell = tableView.DequeueReusableCell("cell"); ListCellViewController cellController = null; if (cell == null || !controllers.ContainsKey(cell.Tag)) { cellController = new ListCellViewController(); NSBundle.MainBundle.LoadNib("ListCellViewController", cellController, null); cell = cellController.Cell; cell.Tag = Environment.TickCount; controllers.Add(cell.Tag, cellController); } else { cellController = controllers[cell.Tag]; } if (toggle) { cell.BackgroundView = new UIImageView(UIImage.FromFile("images/bg1.jpg")); } else { cell.BackgroundView = new UIImageView(UIImage.FromFile("images/bg2.jpg")); } toggle = !toggle; MyDeal d = deals[indexPath.Row]; cellController.SetValues(d.Title,d.Price,d.Value,d.DiscountPercent); GetImage(cellController.Thumbnail,d.Thumbnail); return cell; } private void GetImage(UIImageView img, string url) { img.Alpha = 0; if (url != string.Empty) { if (images.ContainsKey(url)) { img.Image = images[url]; img.Alpha = 1; } else { var context = TaskScheduler.FromCurrentSynchronizationContext (); Task.Factory.StartNew (() => { NSData imageData = NSData.FromUrl(new NSUrl(url)); var uimg = UIImage.LoadFromData(imageData); images.Add(url,uimg); return uimg; }).ContinueWith (t => { InvokeOnMainThread(()=>{ img.Image = t.Result; RefreshImage(img); }); }, context); } } } private void RefreshImage(UIImageView img) { UIView.BeginAnimations("imageThumbnailTransitionIn"); UIView.SetAnimationDuration(0.5f); img.Alpha = 1.0f; UIView.CommitAnimations(); } } } Here is the ListCellViewController, that contains a custom cell using System; using System.Collections.Generic; using System.Linq; using MonoTouch.Foundation; using MonoTouch.UIKit; { public partial class ListCellViewController : UIViewController { #region Constructors // The IntPtr and initWithCoder constructors are required for items that need // to be able to be created from a xib rather than from managed code public ListCellViewController (IntPtr handle) : base(handle) { Initialize (); } [Export("initWithCoder:")] public ListCellViewController (NSCoder coder) : base(coder) { Initialize (); } public ListCellViewController () : base("ListCellViewController", null) { Initialize (); } void Initialize () { } public UIImageView Thumbnail { get{return thumbnailView;} } public UITableViewCell Cell { get {return cell;} } public void SetValues(string title,decimal price,decimal valuex,decimal discount,int purchases) { } #endregion } } All help is greatly appreciated

    Read the article

  • Can someone explain how this IOS Pan Gesture Recognition works? [on hold]

    - by user79894
    It is ios app using Pan Gesture Recognizer It works great, but I didn't get it. I wanna do some changes if the dragged UIView reaches a specific position it would call another method. Any comments are appreciated. - (IBAction)handlePan1:(UIPanGestureRecognizer *)recognizer { CGPoint translation = [recognizer translationInView:self.view]; recognizer.view.center = CGPointMake(recognizer.view.center.x + translation.x, recognizer.view.center.y + translation.y); [recognizer setTranslation:CGPointMake(0, 0) inView:self.view]; /* [x1 setText:[NSString stringWithFormat: @"%.2f", recognizer.view.center.x]]; [y1 setText:[NSString stringWithFormat: @"%.2f", recognizer.view.center.y]]; [x2 setText:[NSString stringWithFormat: @"%.2f", translation.x]]; [y2 setText:[NSString stringWithFormat: @"%.2f", translation.y]];*/ }

    Read the article

  • Problems with transitionWithView and animateWithDuration

    - by MusicMathTech
    I have problems with transitionWithView and animateWithDuration. One of my animateWithDuration blocks doesn't transition, it is a sudden change, and transitionWithView does not temporarily disable user interaction. I have checked the docs and believe I am doing everything correctly, but obviously something is wrong. Here are the two blocks of code: This is in my main View Controller ViewController which has three container views/child view controllers. This block moves one of the container views, but does not block the user from other interactions in ViewController while the transition is occurring. [UIView transitionWithView:self.view duration:0.5 options:UIViewAnimationOptionCurveEaseOut animations:^ { CGRect frame = _containerView.frame; frame.origin.y = self.view.frame.size.height - _containerView.frame.size.height; _containerView.frame = frame; }completion:^(BOOL finished) { // do something }]; This is in one of my container view controllers. The animation seems to have no effect as the text of the productTitleLabel and productDescriptionTextView changes suddenly as if the animation block does not exist. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self.viewController toggleFlavoredOliveOilsTableView]; if (indexPath.row > 0) { NSDictionary *selectedCellDict = [[_flavoredOliveOilsDict objectForKey:@"Unflavored Olive Oils"] objectAtIndex:indexPath.row - 1]; [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionTransitionCrossDissolve animations:^ { self.viewController.productTitleLabel.text = [_flavoredOliveOilsTableView cellForRowAtIndexPath:indexPath].textLabel.text; self.viewController.productDescriptionTextView.text = [selectedCellDict objectForKey:@"Description"]; }completion:nil]; if (indexPath.row == 1) { [self.viewController setProductDescriptionTextViewFrameForInformationTab]; } else { [self.viewController setProductDescriptionTextViewFrameForNonInformationTab]; //self.viewController.productImageView.image = [UIImage imageNamed:[selectedCellDict objectForKey:@"Image"]]; } } } I think the problems are somewhat related as most of my animation and transition blocks don't work completely as expected. Thanks for any help. Edit What I am trying to accomplish is moving a container view in ViewController and set the text and image properties of a label, text view, and image view; all of which are in the main view. The details of these properties are sent via the child view controller. The transitionWithView is in a method called toggleFlavoredOiveOilsTableView which is called in didSelectRowAtIndexPath. I think the problem is that I am trying to call two different animation/transition blocks at the same time.

    Read the article

  • Custom UIViewController is not responsive to device rotation

    - by Wayne Lo
    I have a custom UIViewController, which is the only subView of UIView. The UIViewController contains delegate function: (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } This function is called once when the application starts and is never called again when the device is rotated. I also notice that the willRotateToInterfaceOrientation function is never called. I pretty much commented out all the content in the UIViewController but it is still not responding to device rotation.

    Read the article

  • iPhone Tableview Use Cells in Horizontal Scrolling not Vertical

    - by norskben
    Hi Guys This is not an uiview orientation question, I want to Have the iphone in Portrait or Landscape, and I want a standard tableview(controller?) that will display cells in a vertical strip down the iphone and the tableview scrolls horizontally. -I.e. a 100% normal tableview, that is rotated 90deg without rotating the phone orientation Is this possible?

    Read the article

  • iOS static Framework crash when animating view

    - by user1439216
    I'm encountering a difficult to debug issue with a static library project when attempting to animate a view. It works fine when debugging (and even when debugging in the release configuration), but throws an error archived as a release: Exception Type: EXC_CRASH (SIGSYS) Exception Codes: 0x00000000, 0x00000000 Crashed Thread: 0 Thread 0 name: Dispatch queue: com.apple.main-thread Thread 0 Crashed: 0 TestApp 0x000d04fc 0x91000 + 259324 1 UIKit 0x336d777e +[UIView(UIViewAnimationWithBlocks) animateWithDuration:animations:] + 42 2 TestApp 0x000d04de 0x91000 + 259294 3 TestApp 0x000d0678 0x91000 + 259704 4 Foundation 0x355f04f8 __57-[NSNotificationCenter addObserver:selector:name:object:]_block_invoke_0 + 12 5 CoreFoundation 0x35aae540 ___CFXNotificationPost_block_invoke_0 + 64 6 CoreFoundation 0x35a3a090 _CFXNotificationPost + 1400 7 Foundation 0x355643e4 -[NSNotificationCenter postNotificationName:object:userInfo:] + 60 8 UIKit 0x33599112 -[UIInputViewTransition postNotificationsForTransitionStart] + 846 9 UIKit 0x335988cc -[UIPeripheralHost(UIKitInternal) executeTransition:] + 880 10 UIKit 0x3351bb8c -[UIPeripheralHost(UIKitInternal) setInputViews:animationStyle:] + 304 11 UIKit 0x3351b260 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:] + 952 12 UIKit 0x3351ae54 -[UIResponder(UIResponderInputViewAdditions) reloadInputViews] + 160 13 UIKit 0x3351a990 -[UIResponder becomeFirstResponder] + 452 14 UIKit 0x336194a0 -[UITextInteractionAssistant setFirstResponderIfNecessary] + 168 15 UIKit 0x33618d6a -[UITextInteractionAssistant oneFingerTap:] + 1602 16 UIKit 0x33618630 _UIGestureRecognizerSendActions + 100 17 UIKit 0x335a8d5e -[UIGestureRecognizer _updateGestureWithEvent:] + 298 18 UIKit 0x337d9472 ___UIGestureRecognizerUpdate_block_invoke_0541 + 42 19 UIKit 0x33524f4e _UIGestureRecognizerApplyBlocksToArray + 170 20 UIKit 0x33523a9c _UIGestureRecognizerUpdate + 892 21 UIKit 0x335307e2 _UIGestureRecognizerUpdateGesturesFromSendEvent + 22 22 UIKit 0x33530620 -[UIWindow _sendGesturesForEvent:] + 768 23 UIKit 0x335301ee -[UIWindow sendEvent:] + 82 24 UIKit 0x3351668e -[UIApplication sendEvent:] + 350 25 UIKit 0x33515f34 _UIApplicationHandleEvent + 5820 26 GraphicsServices 0x376d5224 PurpleEventCallback + 876 27 CoreFoundation 0x35ab651c __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 32 28 CoreFoundation 0x35ab64be __CFRunLoopDoSource1 + 134 29 CoreFoundation 0x35ab530c __CFRunLoopRun + 1364 30 CoreFoundation 0x35a3849e CFRunLoopRunSpecific + 294 31 CoreFoundation 0x35a38366 CFRunLoopRunInMode + 98 32 GraphicsServices 0x376d4432 GSEventRunModal + 130 33 UIKit 0x33544cce UIApplicationMain + 1074 Thread 0 crashed with ARM Thread State: r0: 0x0000004e r1: 0x000d04f8 r2: 0x338fed47 r3: 0x3f523340 r4: 0x00000000 r5: 0x2fe8da00 r6: 0x00000001 r7: 0x2fe8d9d0 r8: 0x3f54cad0 r9: 0x00000000 r10: 0x3fd00000 r11: 0x3f523310 ip: 0x3f497048 sp: 0x2fe8d988 lr: 0x33539a41 pc: 0x000d04fc cpsr: 0x60000010 To give some background info: The static library is part of an 'iOS fake-framework', built using the templates from here: https://github.com/kstenerud/iOS-Universal-Framework The framework presents a registration UI as a modal view on top of whatever the client application is doing at the time. It pushes these views using a handle to a UIViewController provided by the client application. It doesn't do anything special, but here's the animation code: -(void)keyboardWillShowNotification:(NSNotification *)notification { double animationDuration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; dispatch_async(dispatch_get_main_queue(), ^(void) { [self animateViewsToState:kUMAnimationStateKeyboardVisible forIdiom:[UIDevice currentDevice].userInterfaceIdiom forDuration:animationDuration]; }); } -(void)animateViewsToState:(kUMAnimationState)state forIdiom:(UIUserInterfaceIdiom)idiom forDuration:(double)duration { float fieldOffset; if (idiom == UIUserInterfaceIdiomPhone) { if (state == kUMAnimationStateKeyboardVisible) { fieldOffset = -KEYBOARD_HEIGHT_IPHONE_PORTRAIT; } else { fieldOffset = KEYBOARD_HEIGHT_IPHONE_PORTRAIT; } } else { if (state == kUMAnimationStateKeyboardVisible) { fieldOffset = -IPAD_FIELD_OFFSET; } else { fieldOffset = IPAD_FIELD_OFFSET; } } [UIView animateWithDuration:duration animations:^(void) { mUserNameField.frame = CGRectOffset(mUserNameField.frame, 0, fieldOffset); mUserPasswordField.frame = CGRectOffset(mUserPasswordField.frame, 0, fieldOffset); }]; } Further printf-style debugging shows that it crashes whenever I do anything much with UIKit - specifically, it crashes when I replace -animateViewsToState with: if (0 == UIUserInterfaceIdiomPhone) { NSLog(@""); } and [[[[UIAlertView alloc] initWithTitle:@"test" message:@"123" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil] autorelease] show]; To me, this sounds like a linker problem, but I don't understand how such problems would only manifest here, and not beforehand. Any help would be greatly appreciated.

    Read the article

  • MKMapView memory usage grows out of control with setRegion: calls

    - by Kurt
    Hi, I have a single MKMapView instance that I have programmatically added to a UIView. As part of the UI, the user can cycle through a list of addresses and the map view is updated to show the correct map for each address as the user goes through them. I create the map view once, and simply change what it displays with setRegion:animated:. The problem is that each time the map is changed to show a new address, the memory usage of my program increases by 200K-500K (as reported by Memory Monitor in Instruments). According to Object Allocations, it appears that a lot of 1.0K Mallocs are happening each time, and the Extended Detail pane for these 1.0K allocations shows that the Responsible Caller is convert_image_data and the Extended Detail pane shows that this is the result of [MKMapTileView drawLayer:inContext:]. So, seems likely to me that the memory usage is due to MKMapView not freeing memory it uses to redraw the map each time. In fact, when I don't display the map at all (by not even adding it as a subview of my main UIView) but still cycle through the addresses (which changes various UILabels and other displayed info) the memory usage for the app does NOT increase. If I add the map view but never update it with setRegion:, the memory also does NOT increase when changing to a new address. One more bit of info: if I go to a new address (and therefore ask the map to display the new address) the memory jumps as described above. However, if I go back to an address that was already displayed, the memory does not jump when the map redraws with the old address. Also, this happens on iPad (real device) with 3.2 and on iPhone (again, real device) with 3.1.2. Here's how I initialize the MKMapView (I only do this once): CGRect mapFrame; mapFrame.origin.y = 460; // yes, magic numbers. just for testing. mapFrame.origin.x = 0; mapFrame.size.height = 500; mapFrame.size.width = 768; mapView = [[MKMapView alloc] initWithFrame:mapFrame]; mapView.delegate = self; [self.view insertSubview:mapView atIndex:0]; And in response to the user selecting an address, I set the map like so: MKCoordinateRegion region; MKCoordinateSpan span; span.latitudeDelta=kStreetMapSpan; // 0.003 span.longitudeDelta=kStreetMapSpan; // 0.003 region.center = address.coords; // coords is CLLocationCoordinate2D region.span = span; mapView.region.span = span; [mapView setRegion:region animated:NO]; Any thoughts? I've scoured the net but haven't seen mention of this problem, and I've reached the limits of my Instruments knowledge. Thanks for any ideas.

    Read the article

  • EXC_BAD_ACCESS error on a UITableView with ARC?

    - by Arnaud Drizard
    I am building a simple app with a custom bar tab which loads the content of the ViewController from a UITableView located in another ViewController. However, every time I try to scroll on the tableview, I get an exc_bad_access error. I enabled NSzombies and guard malloc to get more info on the issue. In the console I get: "message sent to deallocated instance 0x19182f20" and after profiling I get: # Address Category Event Type RefCt Timestamp Size Responsible Library Responsible Caller 56 0x19182f20 FirstTabBarViewController Zombie -1 00:16.613.309 0 UIKit -[UIScrollView(UIScrollViewInternal) _scrollViewWillBeginDragging] Here is a bit of the code of the ViewController in which the error occurs: .h file: #import <UIKit/UIKit.h> #import "DataController.h" @interface FirstTabBarViewController : UIViewController <UITableViewDelegate, UITableViewDataSource> { IBOutlet UITableView* tabBarTable; } @property (strong, nonatomic) IBOutlet UIView *mainView; @property (strong, nonatomic) IBOutlet UITableView *tabBarTable; @property (nonatomic, strong) DataController *messageDataController; @end .m file: #import "FirstTabBarViewController.h" #import "DataController.h" @interface FirstTabBarViewController () @end @implementation FirstTabBarViewController @synthesize tabBarTable=_tabBarTable; - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { // Custom initialization } return self; } - (void)viewDidLoad { [super viewDidLoad]; } - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. } - (void)awakeFromNib { [super awakeFromNib]; self.messageDataController=[[DataController alloc] init]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1; } - (NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ return [self.messageDataController countOfList]; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"mainCell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil){ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; }; NSString *expenseAtIndex = [self.messageDataController objectInListAtIndex:indexPath.row]; [[cell textLabel] setText:expenseAtIndex]; return cell; } - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath { // Return NO if you do not want the specified item to be editable. return NO; } @end This FirstTabBarViewController is loaded in the MainViewController with the following custom segue: #import "customTabBarSegue.h" #import "MainViewController.h" @implementation customTabBarSegue -(void) perform { MainViewController *src= (MainViewController *) [self sourceViewController]; UIViewController *dst=(UIViewController *)[self destinationViewController]; for (UIView *view in src.placeholderView.subviews){ [view removeFromSuperview]; } src.currentViewController =dst; [src.placeholderView addSubview:dst.view]; } @end The Datacontroller class is just a simple NSMutableArray containing strings. I am using ARC so I don't understand where the memory management error comes from. Does anybody have a clue? Any help much appreciated ;) Thanks!!

    Read the article

  • Center content of UISCrollView when smaller

    - by hgpc
    I have an UIImageView inside a UIScrollView which I use for zooming and scrolling. If the image/content of the scroll view if bigger than the scroll view everything works fine. However, when the image becomes smaller than the scroll view, it sticks to the top left corner of the scroll view. I would like to keep it centered, like the Photos app. Any ideas or examples about keeping the content of the UIScrollView centered when smaller? I am working with iPhone 3.0. The following code almost works. The image returns to the top left corner if I pinch it after reaching the minimum zoom level. - (void)loadView { [super loadView]; // set up main scroll view imageScrollView = [[UIScrollView alloc] initWithFrame:[[self view] bounds]]; [imageScrollView setBackgroundColor:[UIColor blackColor]]; [imageScrollView setDelegate:self]; [imageScrollView setBouncesZoom:YES]; [[self view] addSubview:imageScrollView]; UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"WeCanDoIt.png"]]; [imageView setTag:ZOOM_VIEW_TAG]; [imageScrollView setContentSize:[imageView frame].size]; [imageScrollView addSubview:imageView]; CGSize imageSize = imageView.image.size; [imageView release]; CGSize maxSize = imageScrollView.frame.size; CGFloat widthRatio = maxSize.width / imageSize.width; CGFloat heightRatio = maxSize.height / imageSize.height; CGFloat initialZoom = (widthRatio heightRatio) ? heightRatio : widthRatio; [imageScrollView setMinimumZoomScale:initialZoom]; [imageScrollView setZoomScale:1]; float topInset = (maxSize.height - imageSize.height) / 2.0; float sideInset = (maxSize.width - imageSize.width) / 2.0; if (topInset < 0.0) topInset = 0.0; if (sideInset < 0.0) sideInset = 0.0; [imageScrollView setContentInset:UIEdgeInsetsMake(topInset, sideInset, -topInset, -sideInset)]; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return [imageScrollView viewWithTag:ZOOM_VIEW_TAG]; } /************************************** NOTE **************************************/ /* The following delegate method works around a known bug in zoomToRect:animated: */ /* In the next release after 3.0 this workaround will no longer be necessary */ /**********************************************************************************/ - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale { [scrollView setZoomScale:scale+0.01 animated:NO]; [scrollView setZoomScale:scale animated:NO]; // END Bug workaround CGSize maxSize = imageScrollView.frame.size; CGSize viewSize = view.frame.size; float topInset = (maxSize.height - viewSize.height) / 2.0; float sideInset = (maxSize.width - viewSize.width) / 2.0; if (topInset < 0.0) topInset = 0.0; if (sideInset < 0.0) sideInset = 0.0; [imageScrollView setContentInset:UIEdgeInsetsMake(topInset, sideInset, -topInset, -sideInset)]; }

    Read the article

  • iPhone static libraries: How to hide instance variable

    - by Frenzy
    I'm creating a static library to share using the following guide: http://www.amateurinmotion.com/articles/2009/02/08/creating-a-static-library-for-iphone.html In one of the functions, I return a "SomeUIView" which is a subclass of UIView and is defined in the public header, however I don't want to expose the internal instance variable of SomeUIView in the public header. I've tried using categories for a private internal header file for SomeUIView, but I keep running into "Duplicate interface declaration for class 'SomeUIView'". Does anyone know how to do this? Thanks!

    Read the article

  • Animate move and scale of image UIButton

    - by Sam V
    I want it to be animated so I'm using [UIView beginAnimations] I've tried animating using button.imageView.frame (with image set as imageView) but it only animates the position, the image doesn't get scaled down at all. using hateButton.frame (when image is set as backgroundImage), the backgroundImage gets scaled down but it's not animated. How do I animate-scale a UIButton image?

    Read the article

  • iPhone Title and Subtitle in Navigation Bar

    - by Reuven
    Hi there, In my application, I'd like to have the navigation bar display a title and subtitle. To that extent, I added the following code to my view controller: // Replace titleView CGRect headerTitleSubtitleFrame = CGRectMake(0, 0, 200, 44); UIView* _headerTitleSubtitleView = [[[UILabel alloc] initWithFrame:headerTitleSubtitleFrame] autorelease]; _headerTitleSubtitleView.backgroundColor = [UIColor clearColor]; _headerTitleSubtitleView.autoresizesSubviews = YES; CGRect titleFrame = CGRectMake(0, 2, 200, 24); UILabel *titleView = [[[UILabel alloc] initWithFrame:titleFrame] autorelease]; titleView.backgroundColor = [UIColor clearColor]; titleView.font = [UIFont boldSystemFontOfSize:20]; titleView.textAlignment = UITextAlignmentCenter; titleView.textColor = [UIColor whiteColor]; titleView.shadowColor = [UIColor darkGrayColor]; titleView.shadowOffset = CGSizeMake(0, -1); titleView.text = @""; titleView.adjustsFontSizeToFitWidth = YES; [_headerTitleSubtitleView addSubview:titleView]; CGRect subtitleFrame = CGRectMake(0, 24, 200, 44-24); UILabel *subtitleView = [[[UILabel alloc] initWithFrame:subtitleFrame] autorelease]; subtitleView.backgroundColor = [UIColor clearColor]; subtitleView.font = [UIFont boldSystemFontOfSize:13]; subtitleView.textAlignment = UITextAlignmentCenter; subtitleView.textColor = [UIColor whiteColor]; subtitleView.shadowColor = [UIColor darkGrayColor]; subtitleView.shadowOffset = CGSizeMake(0, -1); subtitleView.text = @""; subtitleView.adjustsFontSizeToFitWidth = YES; [_headerTitleSubtitleView addSubview:subtitleView]; _headerTitleSubtitleView.autoresizingMask = (UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin); self.navigationItem.titleView = _headerTitleSubtitleView; And also implemented a method: -(void) setHeaderTitle:(NSString*)headerTitle andSubtitle:(NSString*)headerSubtitle { assert(self.navigationItem.titleView != nil); UIView* headerTitleSubtitleView = self.navigationItem.titleView; UILabel* titleView = [headerTitleSubtitleView.subviews objectAtIndex:0]; UILabel* subtitleView = [headerTitleSubtitleView.subviews objectAtIndex:1]; assert((titleView != nil) && (subtitleView != nil) && ([titleView isKindOfClass:[UILabel class]]) && ([subtitleView isKindOfClass:[UILabel class]])); titleView.text = headerTitle; subtitleView.text = headerSubtitle; } Things work beautifully, thanks. Except that when rotating the iPhone to Landscape, the title+subtitle don't downsize in an automatic manner like the default title of the navigation item. Any pointers? Thanks!

    Read the article

  • touchEvent in UIScrollview?

    - by senthilmuthu
    i am using ScrollviewDelegate Protocol in viewcontroller.but i am using Custom UIView(UIImageview)in that custom view touch began, touch ended is working ,but touchMoved is not called.how can i achieve this one?

    Read the article

  • UIDatePicker questions regarding displaying

    - by Zap
    Does anyone know if it's possible to change the minute interval of a UIDatePicker after it's been added to a UIView? Is it possible to show and hide 2 different datePickers? I want change the minuteInterval of the UIDatePicker to 5 and 30 when I click a button. Any sample code would be appreciated.

    Read the article

< Previous Page | 28 29 30 31 32 33 34 35 36 37 38 39  | Next Page >