uiviewcontroller

disable UIViewController content animating on iPhone rotation

Hi! I need to implement behavior of my UIViewController subclass like in standart iPod.app: when device rotated from portrait to landscape, content of UIViewController stay's still and new view add's above it. The problem is that, when set - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { ...

Organizing instance variables in a view hierarchy

When programming for the iPhone, I find that I often need to use the same instance of an object in multiple views. What is the best way to handle this? My strategy so far has been to create it as a member of the root view and pass it to subsequent views which retain it as a member. However, this does not seem like a very good approach...

How to choose what code to put in a View vs. a ViewController?

In Xcode, the Utility Application template makes a project with: MainView, MainViewController and FlipsideView, FlipsideViewController In my app, the two views correspond to the main UI and a preferences screen. Obviously I want the prefs to be reflected in the main UI and persisted to disk to remember settings. I know how to do that...

Instantiate a new instance of UIViewController within itself

I have an instance of UIViewController displaying a list of items. When the user selects an item I need to create a new instance of UIViewController (populated by a different list of items) and show it. At the moment I'm calling the constructor from within the didSelectRowAtIndexPath method RootViewController *rootViewController = ...

Portrait UITabBarController on one view, Landscape view on another UIView, not working.

Hello guys, and heres the deal. Im trying to get a few of my views to play nicely together, but unfortunately i must be missing something. heres the over view i have Application Delegate UIViewController containing a tabbarcontroller UiViewController containing an OpenGL view (needs to be landscape) The application Delgate handles ...

Why doesn't initWithNibName work for my UIViewController subclass?

I have subclassed UIViewController into a new class, PageViewController (I'm writing a simple book app). I want to add a new view loaded from a nib file and am using the following code. It works. PageViewController *viewController1 = [[UIViewController alloc] initWithNibName:@"Page1" bundle:nil]; [viewController1.view setUserInteraction...

My UIViewController is "lying" about its center property

I'm asking my ViewController for it's view.center property and drawing a new UIView that centers itself around this "center"... I am getting (160, 250) as a response. but when the new UIView draws it's below center... So I'm wondering who's giving me this info and what it relates to? This is clearly where the center of the view is in re...

Reconstituting objects from nib - Just add water? maybe not...

Much I've read talks about the advantages of setting your UI up in IB. And how when the nib is "awoken" all the objects in it "come to life". I'm experimenting with placing about 10 UIView objects into a nib that is owned by a ViewController. The UIView objects are of type MyView and are wired back to their respective properties in the...

UIViewController: detecting drill-down and drill-up

Is there a way for a UIViewController (inside a navigation stack) to detect whether it is appearing because a drill-down or a drill-up was performed? In viewWillAppear, the UINavigationController's topViewController and visibleViewController are already set to the new ViewController, unfortunately. ...

How to position view relative to parent?

I have a UIViewController with an MKMapView in it. In viewDidLoad of this controller, I add the MKMapView: [self.view addSubview:mapView]; I want to display this map in a tableview cell. In the tableview controller's cellForRowAtIndexPath:, I do this: [cell addSubview:mapView.view]; where cell is a UITableViewCell. I've set the ...

viewDidLoad getting called twice on rootViewController at launch

Anyone know why this root View Controller's viewDidLoad is being called twice at launch? It's driving me nuts! here's the stack trace from first time through viewDidLoad: #0 0x0000276a in -[RootViewController viewDidLoad] at RootViewController.m:71 #1 0x3097548f in -[UIViewController view] #2 0x00002734 in -[RootViewController init...

Animating Touches to Objects - can I get object of touched view?

I'd like to get a reference to the object whose view was touched on the iPhone. I'm probably just approaching this the wrong way so let me try to explain what trying to do... I have various instances of a sub-classed UIImageView with some custom value properties. The user can touch and move them. Depending on where they go I'd like to...

presentModalViewController crashes my app

It's one of the simplest things to do, I know. But I've been banging my head against this for days. I've done it plenty of times in the past, but for some reason trying to present a modal view controller just crashes the app to a black screen. Nothing reported in the console or anything. I'm hoping someone might have had this problem and...

iphone - adding the view of MFMailComposeViewController (in-app email)

I've spent the past two days just trying to enable the sending of email from within my app. Hoping one of the smart folks on here can help me out. presentModalViewController doesn't work for me (just crashes the app with no explanation as to why), so I'm forced to add the view of MFMailComposeViewController. Here's my attempt: MFMailCom...

Can't release object without crashing

In a tableview cellForRowAtIndexPath, I do the following: MapViewController *mapView = [[MapViewController alloc] initWithCoordinates:city.Latitude longitude:city.Longitude]; [cell addSubview:mapView.view]; //[mapView release]; -- will crash here Calling the last line gives this memory error EXC__BAD _ACCESS”. How do I release the ab...

Simplifying a complicated Cocoa-Touch View Controller

As I wire up my first fairly complicated Cocoa-Touch view I feel like I'm inadvertently slipping back into old procedural patterns and finding it difficult to shake them off...Though fully aware of many of the Cocoa (OO) design patterns I'm afraid I may be subverting them. As such this view in question is quickly becoming unmanageable a...

Ignore touches to background (super) view

How should I be handling, or rather NOT handling (ignoring), touches to my background view? It happens to be the view of my View Controller which has subviews (objects) that I DO want to respond to touch events. Setting userInteractionEnabled = NO for the view seems to turn off ALL interaction for the subviews as well. I'm currently te...

Displaying MFMailComposeViewController in landscape

My app is landscape based. I'd like to use MFMailComposeViewController in landscape but can't find anything to notifiy it about orientation. In landscape, MFMailComposeViewController displays only the top part of the mail compose window, coming in from the left side, when in landscape. Basically it covers half of the landscape screen....

Logical error or is my program skipping parts?

FYI I'm programming in objective-C but anyone might be able to help. I've been sitting here for the past two hours trying to figure out what the problem is and I've done everything I know to debug this simple little coding problem. Check out the code below and I will explain. In the application, it starts out with MainScreenViewControlle...

Where to determine UIView size

Summary: How should the UIViewController know the size of its UIView instance when initializing that view? The dedicated initialization method for an UIView is the initWithFrame:(CGRect)frame method. This sets the frame for the newly created UIView. This method could be called from the UIViewController's loadView method, if that view co...