exploring the gui
Download
Skip this Video
Download Presentation
Exploring the GUI

Loading in 2 Seconds...

play fullscreen
1 / 11

Exploring the GUI - PowerPoint PPT Presentation


  • 129 Views
  • Uploaded on

Exploring the GUI. What if we want to add a UIView (for example a UILabel) at run time inside the navigation bar? We need to access that view, create a label, and add it as a subview How do we find that view?. Exploring the GUI. From a UIView named myView, we can go up

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Exploring the GUI' - wilda


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
exploring the gui
Exploring the GUI
  • What if we want to add a UIView (for example a UILabel) at run time inside the navigation bar?
  • We need to access that view, create a label, and add it as a subview
  • How do we find that view?
exploring the gui1
Exploring the GUI
  • From a UIView named myView, we can go up
  • myView.superview (a UIView)
  • or down
  • myView.subviews (a NSArray of UIViews)
exploring the gui2
Exploring the GUI
  • From a UIViewController named myVC, we can go up
  • myVC.parentViewController (a UIViewController)
  • or down
  • myVC.childViewControllers (a NSArray of UIViewControllers)
exploring the gui3
Exploring the GUI
  • Inside the DetailViewController, get the parent view controller, look at its view, and the children of its view
  • UIViewController *parentC = self.parentViewController;
  • UIView *topView = parentC.view;
  • NSArray *views = topView.subviews;
exploring the gui4
Exploring the GUI
  • Use NSLog to output the views: there are 2 of them
  • iPad dimensions are:
  • UINavigationTransitionView: 0, 0, 703, 768
  • UINavigationBar: 0, 20, 703, 44
  •  navigation bar is on top and its height is 44 pixels
exploring the gui5
Exploring the GUI
  • Get the navigation bar view
  • UINavigationBar *bar = (UINavigationBar *) [views objectAtIndex: 1];
  • Now place a label inside it
exploring the gui6
Exploring the GUI
  • Run the app, back and forth
  • The label stays when we go back
  • Inside the viewWillAppear method of MasterViewController, we can remove it
exploring the gui7
Exploring the GUI
  • If we have a method named removeLabel in the DetailViewController class, we could call it from viewWillAppear inside the MasterViewController class
  • [self.detailViewController removeLabel];
exploring the gui8
Exploring the GUI
  • Inside removeLabel, we could search for the label, based on some characteristics (class name, color, text, ..)
  • Better, we can tag it when we add it
  • UIView has a property named tag (NSInteger)
  • label.tag = 99;
exploring the gui9
Exploring the GUI
  • From a parent view, we can use the method viewWithTag (searches current view and subviews) to retrieve the label
  • UILabel *label = [someParentView viewWithTag: 99];
  • Now remove it
  • [label removeFromSuperview];
exploring the gui10
Exploring the GUI
  • We could also declare the UILabel as an instance variable, create it when the view loads, and then set it visible or invisible using the hidden property
  • label.hidden = YES;
  • label.hidden = NO;
ad