how to release controller after jump to other page or remove view title bar - release

in my code I call tab bar controller like this:
[[TTNavigator navigator] openURLAction:[TTURLAction actionWithURLPath:#"tt://tabBar"]];
For the first page which tab bar called like this:
- (id)init{
if (self = [super init]) {
self.title = #"app";
UIImage* image = [UIImage imageNamed:#"tab.png"];
self.tabBarItem = [[[UITabBarItem alloc] initWithTitle:self.title image:image tag:0] autorelease];
self.variableHeightRows = YES;
id<TTTableViewDataSource> ds = [MainPageDataSource dataSourceWithItems:nil];
ds.model = CreateTabModelWithCurrentSettings();
self.dataSource = ds;
}
return self;}
-(void)loadView{
self.view = [[[UIView alloc] initWithFrame:TTApplicationFrame()] autorelease];
self.tableView = [[[UITableView alloc] initWithFrame:TTApplicationFrame() style:UITableViewStylePlain] autorelease];
self.tableView.rowHeight = 80.f;
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.tableView];}
As shown above.
how to remove the "back" title?
how to remove both of title?
Actually I found that the back navigate bar is previous login page's, so is there any way to release the previous login page after the tab bar controller has been called

Take a look on this tutorial. It explains how to hide the tab bar when you push a login view.
http://three20.info/article/2010-11-10-Hiding-The-iphone-Tab-Bar-With-TTNavigator
Note that it makes more sense to show your tab bar main controller, and push the login view in case the user isn't logged in. This way you can release the login view and come back to the main tab bar view.
Also, if you have issues with duplicated UINavigationBar bars, you should use the [TTURLMap from:(NSString*)URL toModalViewController:(id)target] function, which present controllers that already has UINavigationBar
`

Related

MFSideMenu in UINavigationController not working when introduced with a modal Segue

I'm trying to integrate MFSideMenu in my project but I don't want to adopt the approach described in the GitHub depository as it defines the menu in the app delegate.
I have a login screen which will introduce a navigation controller with the main page as reported in this picture
I would like to add the support for MFSideMenu in the navigationcontroller root controller using this code:
- (id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
// Custom initialization
self.sideMenuController = [[SideMenuViewController alloc] init];
UINavigationController *navigationController = self.navigationController;
MFSideMenuOptions options = MFSideMenuOptionMenuButtonEnabled|MFSideMenuOptionBackButtonEnabled
|MFSideMenuOptionShadowEnabled;
MFSideMenuPanMode panMode = MFSideMenuPanModeNavigationBar|MFSideMenuPanModeNavigationController;
MFSideMenu *sideMenu = [MFSideMenu menuWithNavigationController:navigationController
sideMenuController:sideMenuController
location:MFSideMenuLocationLeft
options:options
panMode:panMode];
sideMenuController.sideMenu = sideMenu;
}
return self;
}
When I run the app the menu button appears in my navigation bar and everything seems working fine but,if I introduce the navigation controller through a modal segue (i.e. a login screen which goes to the navigation controller in case of a correct login) the button disappears.
Any idea about how to fix it?

Unexpected behavior of a Modal View displaying a YouTube video in a UIWebView

I have a view based application (no storyboards) with a button that presents a modal view with a webview in it. The webview loads a YouTube video and the user taps it and watches the video in full screen.
When the video ends (or the user taps "done"), the video player dismisses, but for some reason I see the Main View instead of the modal view controller (and I can't invoke the modal view again with the button, although the IBAction is being called)...
The present modal view code (in the Main View controller):
SomeViewController *controller = [[[SomeViewController alloc] initWithNibName:#"SomeViewController_iPhone" bundle:nil] autorelease];
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
Then, in "SomeViewController", I have a UIWebView that loads the YouTube video:
- (void)embedYouTube:(NSString *)urlString frame:(CGRect)frame {
NSString *embedHTML = #"\
<html><head>\
<style type=\"text/css\">\
body {\
background-color: transparent;\
color: white;\
}\
</style>\
</head><body style=\"margin:0\">\
<embed id=\"yt\" src=\"%#\" type=\"application/x-shockwave-flash\" \
width=\"%0.0f\" height=\"%0.0f\"></embed>\
</body></html>";
NSString *html = [NSString stringWithFormat:embedHTML, urlString, frame.size.width, frame.size.height];
[self.webView loadHTMLString:html baseURL:nil];
}
The video plays just fine, but when it's done, it's get dismissed and the Main View is being showed instead of the Modal View (SomeViewController).
No error is being given though.
From what I understand, the video player is also a modal view, so the hierarchy is something like this:
-- Main View
---- Modal View (SomeViewController with WebView)
-------- Video Modal View (invoked by the WebView)
So I don't get why is the Main View controller being shown after the Video is done playing, and why it doesn't let me invoke the modal view controller again...
Thanks for any help!

loading uiwebview from specified location

//Move to bookmarked place if page is opened from bookmark section.
- (void)webViewDidFinishLoad:(UIWebView *)webView1;
{
if(chkview == 2)
{
//Move webview to chkScrollValue position.
[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:#"document.body.scrollTop = %d", chkScrollValue]];
// [webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:#"window.scrollBy(0,%d);",chkScrollValue]];
}
}
I'm loading my webview which was displaying html which was in resources folder and it was working fine. Now, i'm using javascript with html and this is not working anymore.
I got the solution. I was performing this task after webViewDidFinishLoad. Rather than that now I added another function and added this code in function
[self performSelector:#selector(loadBookmark) withObject:nil afterDelay:0.4];

How to disable zoom glass/lens from UIWebView?

I have disable default call out action sheet from UIWebView by using this -
[webView stringByEvaluatingJavaScriptFromString:#"document.body.style.webkitTouchCallout='none';"];
it's working fine but the main problem is that when i tap on an image for a long time a zoom lens of UIWebView comes there and i want to disable it, is it possible? then how?
Yes a few ways but some of which are buggy.
If you don't care about userinteraction at all you can just disabled it. Then they will only be able to zoom and move around the page (but not click any links or anything).
-(void)removeInput{
UIScrollView *webViewContentView;
for (UIView *checkView in [webView subviews] ) {
if ([checkView isKindOfClass:[UIScrollView class]]) {
webViewContentView = (UIScrollView*)checkView;
break;
}
}
for (UIView *checkView in [webViewContentView subviews] ) {
checkView.userInteractionEnabled = NO;
}
}
UIWebView without Copy/Paste and selection rectangle when showing documents
However that causes all userInteraction to be disabled which might not be what you want?
To JUST disable the magnifying glass I don't think is possible (though I might be wrong?).
Ok if you don't mind disabling the text selection as well you can try this.
ObjC
[webView stringByEvaluatingJavaScriptFromString:#"document.onmousedown = function() {return false;}"];
JavaScript
document.onselectstart = function() {return false;} // ie
document.onmousedown = function() {return false;}
Source:
http://javascript.internet.com/page-details/disable-text-selection.html

How to tell the difference between touchesBegan and touchesMoved

How can I ignore the touchesBegan method when the user is pinching an object and ignore the touchesMoved method when the user taps on the screen? I created a picture zoom in / zoom out effect and I want to be able to hide the navigation bar when the user taps on the screen once. Right now when the user starts pinching, the navigation bar gets displayed since the user touched once.
What would be the best way to do this?
It seems like the easiest thing to do for your show/hide navigation bar would be to add a UITapGestureRecognizer and set numberOfTouchesRequired and numberOfTapsRequired to 1.
Alternatively, you could use touchesEnded instead of touchesBegan. Then in your touchesEnded, you could check for the number of touches and only show/hide if it's 1:
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *theTouch = [touches anyObject];
if (theTouch.tapCount == 1) {
// show/hide navigation here ...
} else {
// finish your zoom here ...
}
}

Resources