UIPopOverController for iPhone (currently only available for iPad) - iphone

Before I implement something similar for the iPhone, I'm wondering if anyone has implemented something similar of the UIPopOverController for the iPhone. This is so far only available for iPad.

See my implementation here: https://github.com/werner77/WEPopover
It has the same interface as the UIPopoverController but is generalized for iPhone and with support for custom background views.

I have provided another alternative SGPopoverController at http://github.com/KJoyner/SeaGlass. Like the WEPopover, this has a similar interface to UIPovoerController but works on the iPhone. This version handles more corner cases, works both modally and non-modally, supports passthrough views, and more.

Create
UIPopover+iPhone.h
#import <Foundation/Foundation.h>
#interface UIPopoverController (overrides)
+ (BOOL)_popoversDisabled;
#end

There's a reason UIPopoverController isn't a standard UI element on the iPhone, is that screen space is rather restricted. Having a popover, that's easily readable, implies that a fair amount of the iPhone screen will be taken up by the popover. Perhaps you should rethink your UI decision.
Maybe a coverVertical modal view?

Found another git. Looks more updated and actively maintained. it uses QuantzCore to draw the popover, which looks as elegant as iOS's SDK native.
Just for your reference: https://github.com/50pixels/FPPopover

Basically the best way to do this is to implement custom UIAlertView subclasses that look/behave how you want, via custom animations and being able to click behind and disappear (if you want that functionality, as UIPopoverController has it)
Edit: you can also try using a view and presenting it modally, though the animations might not be what you are looking for.

Related

ios - Why is Flipside controller so complicated?

Just a quick question.
I am busy with an iPhone app based on the Utility Application template to set me up with the Core Data info.
I was just wondering, why the FlipViewController is set up the way that it is.
Is it not much easier to do link in storyboard with a modalview segue a
- (IBAction)doneFlip:(id)sender
{
[self dismissModalViewControllerAnimated:YES];
}
To return to the previous view?
Is this a performance reason?
Cheers
Apple's templates are always a mess in Xcode 4.x. For those who can remember way back to Xcode 2.x or even early 3.x, the templates were relatively uniform with excellent comments and very little extra gruff in the way. But in 4.x, the templates have become a jarring mix of coding styles, preferences, and traditions from Apple's many Xcode developers.
As for that:
- (IBAction)doneFlip:(id)sender
{
[self dismissModalViewControllerAnimated:YES];
}
-dismissModalViewController would not be the best thing to use (it should be called from the presenting controller. Use -popViewControllerAnimated instead if it is in an action from inside the presented view.

Return to mainview from webView deployed using storyboard

I created a new project "Single View Application" and designed the mainView with Storyboard. My main view contains a UIButton that opens the camera, the camera scans barcode and automatically goes to a website. Now I created a webView programmatically so that website can open and also created a UIButton inside the webView. Now I want that UIButton to act as home botton and return to mainview. I am unable to do that, please help.
ViewController.m code: http://cl.ly/FKj8
My storyboard looks like:
You really should look into the View Controller Programming Guide -- by switching around the contents of a single view controller, you're making a lot of extra work for yourself with little benefit. By using multiple view controllers when you want to have different "screens" in your app, you can take advantage of storyboarding for easier development, and you automatically get better memory management (read: less potential for crashes), too.
However, to more directly answer your question... if you're putting the WebView into the view hierarchy with [self.view addSubview:webView], you can remove it with [webView removeFromSuperview]. (This means you'll have to keep a reference to the WebView around so you can refer to it when you want to dismiss it.)
I also noticed in the code you posted to cl.ly an unrelated method -deviceModel which uses uname() to get device information. This is a bad idea, for two reasons:
uname() isn't guaranteed to do something useful on an iOS device (even if it currently does). Use the UIDevice class instead if you need this kind of info, or...
Generally, you don't want to test for the device name to enable functionality in your app; instead, you should test for the capabilities you need. (For example, if you look for a device name starting with "iPhone 4" to test for a Retina display, you'll miss the 4th-generation iPod touch, and the iPhone-5-or-whatever-they-call-what's-next. Instead, use the UIScreen class.)

First iPhone Multiview App - Some Guidance

I'm wanting to make a multiview app with 5-6 different screens and a data source to store user information. I've never made a multiview app before, and I have a good idea on how to start, but I'd like to hear some recommendations on "structuring" your app to properly support this.
A very simple analogy could be going about making a background color on a website... You could either use an image of a solid color or simply use the background-color style. Both get the job done, but using the style is a bit easier/more efficient.
I just want to make sure I'm starting off on the right foot. Should I keep all my functions in one class' .m/.h file? What's the best/efficient way to go about different screens?
Thanks, and I'll definitely try to help others out once I get a much better grasp on Objective-C and Xcode.
If you are new to the iPhone/iPad I highly recommend you check out the CS193P lectures, they are also avaliale on itunes. They give a good overview of iPhone programing and how things are done in Objective-C / Cocoa Touch. It will get anyone started in the right direction.
As to your specific question. Just start coding. In 6 months you'll realize eveything you wrote is cr*p and needs to be rewritten anyways, but doing it is the only way you'll realize what you wrote is cr*p so...
Some suggestions, specific to multi-viewed apps (which almost every app is) and I'm sure someone else can expand on this...
Learn (as much as possible) to code interactions between different views and viewcontrollers (vs using interface builder). The twitter app for example doesn't use Interface Builder at all.
If you use IB, don't dump everything into one .xib. Learn how to break them up. One .xib per viewcontroller should be it. I never use the IB UITabBarController or IB UINavigationController, those get initilized and used in code only.
Absolutly learn MVC (Model view controller).
The Apple documentation is often a good place to start for most things. Try here first. Hope this helps and good luck!
I used to use a UINavigationController. I created it as a singleton and accessed it statically so I could push and pop controllers easily (theres a reasonably good tutorial here). This is quite lightweight and theres enough documentation to get going with it quickly.
However the best approach I've used is the Three20 framework's TTNavigator. In a nutshell its a beefed up UINavigator that lets you push a new view onto the screen by calling an internal URL:
//(In your app delegate)
//Start up the navigator
TTNavigator* navigator = [TTNavigator navigator];
navigator.persistenceMode = TTNavigatorPersistenceModeTop;
//Map url's to controllers
TTURLMap* map = navigator.URLMap;
[map from:#"*" toViewController:[TTWebController class]];
[map from:#"ac://search" toViewController:[SearchViewController class]];
[map from:#"ac://results/(initToView:)" toViewController:[ResultsViewController class]];
Then to navigate to a controller:
[[TTNavigator navigator] openURLAction:[[TTURLAction actionWithURLPath:#"ac://results/searchResults/"] applyAnimated:YES]];
Whats also cool is that calling that #"ac://results/" the way we have above passes in the param #"searchResults" to the init method of the ResultsViewController ("initToView:") as we defined in the mapper
All the best!

Possible to use iPhoneSimulators framework in a Cocoa App?

I am toying with the idea of creating a iPhone UI editor that isn't Interface Builder! Mostly to see if it is possible to do... I have been able to link to the UIKit.framework in a Cocoa app that I have created by dynamically loading it (via NSBundle functionality). I have been able to instantiate an UIView from there. Now the question is... how do I get to whatever the UIView renders?
I am trying to figure out how Apple implemented their Simulator since it seems likely that they are using the frameworks under the iPhoneSimulator.platform folder to do the rendering and then displaying that in a Cocoa window...
I am not sure how far I can go with this idea..but if anyone has any ideas how to direct the output of the UIVIew to a bitmap then I could take that and display in my Cocoa window...
Thanks,
Peter
You might try making an NSView subclass that hosts a UIWindow. In the NSView's drawRect:, apply any necessary transformations, then send drawRect: to the UIWindow.
Then, set your simulator NSWindow's content view to an instance of that subclass.

UITabBarController, UINavigationController and autorotate

i have problem with autorotate on iphone
i set up in all classes
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
but it is not respond ;/
Sample code is: http://b6.s3.p.quickshareit.com/files/testautorotatecb367.zip
problem is only with first tab, if i switch application to second tab, and rotate iphone, interface is rotating. it is not rotating in TAB1, where i put custom UINavigationController
OK
problem is that i do not init navigation views, i use only alloc, after i add alloc] init] all started works OK
Okay, i think i see what the problem is in you code. You need to add your UINavigationBar to the delegate like you did with the tab bar, otherwise it doesn't know of its existence and therefore it isn't rotating because it is confused on what is in the view.
Because I use Interface Builder to take care of all my GUI needs, i'm not sure how to do this manually in code, so, to help you out, here >> http://www.radford.edu/ebalci/Tutorials/SimpleTabNavTemplate.zip is a tutorial kind of thing i made a few days ago for a friend, you can use it as sort of a template or guide to help you out (i hope it will help you)
[my tutorial uses UItableViews for navigation but that is optional]
also, i commented out my rotation methods because i wasn't worried about it at the time, but
if you uncomment them (and i think you have to add the method to one of the classes because i deleted it) it will rotate, i just checked, but was too lazy to re zip it and upload it.
I just want you to know that I pretty much just made this thing a day ago, there is a rich text file in the zip that has instructions, but, it is a rough draft, i haven't really revised it yet so, i hope you can read through it with ease despite the fact it is a rough draft.
Let me know if it helps =) Good Luck
And your custom UINavigationController also has the same
shouldAutorotateToInterfaceOrientation
method that returns YES to landscape views?