iOS 5 page curl with custom View Controller - objective-c

I am trying to use page curl to show a sub page using Xcode storyboards. Everything is working when I have the sub page as UIViewController, but when I change it to a custom UIViewController, the sub page is black. Happens both on device and simulator.
iOS 5
Xcode Version 4.2
Anyone seen this before?
Edit: This is happening every time when using a custom UIViewController, no matter if I use push or model. If I use a custom UITableViewController it is fine.

I have in my ViewController which starts the transition this method:
-(void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender{
NSLog(#"prepare segue modal.partial_curl");
if([[segue identifier] isEqualToString: #"sample"]){
"setgoalviewcontrollerobjecthere" = [segue destinationViewController];
}
}
don't forget to import .h file, alloc and init. name segue identifier in storyboard file "sample", and pick style modal, transition partial curl. easiest way works every time. If you do it just programmatically you have to do a lot more -> google
domink

Related

UIImagePickerController in Qt 5.3

I want to implement an application for iOS. I’ve used Qt 5.3 on Mac. I want to defined user interface in Qt. I want to have a button on *.ui. When clicking on that, iOS photo library will be opened and then user can be able to select a photo. I know that I must use UIImagePickerController.
I have to use the root controller and show the UIPickerImageController on that.
For doing so, I need to use some internal Qt API:
first, in the *.pro:
QT += gui-private
then, in my *.mm code get the pointer to the root view controller of the Qt app:
UIView *view = static_cast<UIView *>( QGuiApplication::platformNativeInterface()->nativeResourceForWindow("uiview",quickView) );
UIViewController* rootCtrl = [[view window] rootViewController];
and now, I can show the UIImagePickeController:
[rootCtrl presentViewController:imagePickerController animated:YES completation:nil]
this way to get the root view controller with QML, solved my problem but I don’t want to use QML. Is there another way to get a pointer to the main root view controller of the Qt application(C++ + Objective-C) without using QML?
Thanks!
You can use UIApplication and keyWindow property:
UIViewController* rootViewController = [[UIApplication sharedApplication].keyWindow rootViewController];

Undeclared identifer error in prepareForSegue : using Storyboards in iOS6

I am trying to build a 2 scene application using Storyboards in iOS6.
I am taking the users name via text input in the first scene and passing it using a push segue to the second scene; where it is displayed in a label.
The first scene's UIViewController is called ViewController and the second scenes UIViewcontroller is DrawViewController.
I have imported the the DrawViewController.h in my ViewController.m file where I have defined the prepareForSegue as below:
-(void) prepareForSegue:(UIStoryboardSegue *) segue sender:(id) sender{
if ([segue.identifier isEqualToString:#"ColorPickerControllerSegue"]){
DrawViewController *dvc =[segue destinationViewController];
dvc.userName= self.userName;
}
}
Here userName is a NSString defined in DrawViewController.
I am getting "use of undeclared identifer:DrawViewController".
I am quite new to iOS programming, so is there something I am missing here?
I have set the second view controller's custom class to DrawViewController.
I was able to solve this issue by removing the existing DrawViewController.h and DrawViewController.m files and then creating and adding them back to the the project.
It seemed to do the trick.

How to Properly Switch Between Views

I'm making an iOS app (first actual app that isn't Hello World), and it will have 2 screens. I asked on here before how to make one screen (or View Controller) open another, and this is what I figured out to use:
[self presentViewController:[[self storyboard] instantiateViewControllerWithIdentifier:#"statView"] animated:YES completion:nil];
It works. However, it gives me the following message when this runs:
Unknown class statView in Interface Builder file.
(Note: this doesn't stop me from using the app, it just seems to be a warning.
This leads me to believe I'm doing something wrong. Also, it seems I'm instantiating this new view controller, but never getting rid of it. So when I go back and forth, I imagine I might be leaving these View Controllers instantiated as new every time?
So my question is:
If there is a better way to switch between these windows, how can it be done?
If this is correct, why the error message?
The most easy way is unsing the Storyboard.
Add a button and link it to the second view.
You can use a Segue to parse data:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if([[segue identifier] isEqualToString:#"SEGUENAME"]) {
SecondViewController *secondViewController = [segue destinationViewController];
secondViewController.parameter = parameter; // Parse a value
}
}

textFieldShouldReturn not firing in iPad app

I have an iPad app created using XCode 4 with Storyboard. I have a UITableViewController with the interface defined as such:
#interface CustomerViewController : UITableViewController <UITextFieldDelegate>
In the .m file, I have a code snippet as:
- (BOOL) textFieldShouldReturn:(UITextField *)textField {
if(textField == businessName) {
[email becomeFirstResponder];
return true;
}
The method 'textFieldShouldReturn' does NOT get executed. What else needs to be done? (BTW... I have never been able to get this to work in a iPad app, but always successful in a iPhone app)
In the textFieldShouldReturn method, you're testing if the textField is equal to businessName. I'm assuming that's a UITextField object, but you have to set the delegate to receive callbacks. Just a simple self.businessName.delegate = self; when you create the TextField.
Another tip, I'd recommend calling it something like businessNameTextField. It's easier to read throughout your code.
You have to set the view controller as the delegate of the text field, just declaring that you conform to the protocol isn't enough. If it works in the iPhone but not iPad, then the chances are you haven't linked the delegate outlet in the iPad storyboard, but you have in the iPhone.

iOS 5 MainStoryBoard : When linking a view as PUSH, can we set a property?

I know we still can do it by programmation,.. that's what i'm using for now (as iOS 4).
The old way was to init your controller, set property, then Push.
But with iOS 5, since the main storyboard is the "new" way to design your application.
I was wondering if it is any possible way to do the same, setting a property then pushing using the link in your mainstoryboard ?
It is so easy now to push, but not really useful if you want to set a property....
I don't know if I explained it clearly.. but it is really basic stuff.
Anyone?
You'd now use prepareForSegue: method to do any customisation. You can grab a reference to the view you're about to push and manipulate it, similar to this...
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
// Check we're referring to the right segue
if ([[segue identifier] isEqualToString:#"YOUR_SEGUE_NAME_HERE"])
{
// Get reference to the destination view controller
YourViewController *vc = [segue destinationViewController];
// Do your customisations here
}
}
I just wrote two blog posts on how to do this. You can read it here and it should clarify (with example) how to do it.