Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Vlad1k

macrumors newbie
Original poster
Sep 16, 2013
4
0
Saint Louis, US.
Hey guys!
I am not 100% sure if this is the correct section, but I am creating an app using Theos (without Xcode), and I have an issue. My navigation bar is over the UIViewWeb, so I have to scroll down to view the top part of the UIViewWeb.

Here is a screenshot:
aQ4yuyp.png


Here is my code:
RootViewController.mm
Code:
#import "RootViewController.h"
@implementation RootViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    webview=[[UIWebView alloc]initWithFrame:self.view.bounds];
    NSString *url=@"http://localhost/";
    NSURL *nsurl=[NSURL URLWithString:url];
    NSURLRequest *nsrequest=[NSURLRequest requestWithURL:nsurl];
    [webview loadRequest:nsrequest];
    [self.view addSubview:webview];

    navBar = [[UINavigationBar alloc] init];
    navBar.frame = CGRectMake(0, 0, self.view.frame.size.width, 44);
    UINavigationItem*navItem = [[[UINavigationItem alloc] initWithTitle:@"iPaint"] autorelease];
    UIBarButtonItem*leftButton = [[[UIBarButtonItem alloc] initWithTitle:@"Left" style:UIBarButtonItemStylePlain target:self action:@selector(rightButtonPressed)] autorelease];
    navItem.leftBarButtonItem = leftButton;
UIBarButtonItem*rightButton = [[[UIBarButtonItem alloc] initWithTitle:@"Right" style:UIBarButtonItemStylePlain target:self action:@selector(rightButtonPressed)] autorelease];
    navItem.rightBarButtonItem = rightButton;
navBar.barStyle = UIBarStyleDefault;
    navBar.items = [NSArray arrayWithObject:navItem];
    [self.view addSubview:navBar];
}

-(void)leftButtonPressed{
//Code Here
}

-(void)rightButtonPressed{
//Code Here
}
@end

RootViewController.h
Code:
@interface RootViewController: UIViewController {
UIWebView *webview;
UINavigationBar*navBar;
@end
}

main.m
Code:
int main(int argc, char **argv) {
        NSAutoreleasePool *p = [[NSAutoreleasePool alloc] init];
        int ret = UIApplicationMain(argc, argv, @"comvlad1kwebApplication", @"comvlad1kwebApplication");
        [p drain];
        return ret;
}

Thanks in advanced, I really appreciate it. I am really new to this new Obective-C stuff and it's really complicated right now. If this is in the wrong section, @moderators, please move it to a right one. Thank you. :D
 
Just curious: why are you using Theos instead of Xcode? If you were using Xcode you could use its interface builder tool which would get rid of most of the code you've written so far, and I suspect you wouldn't end up with the bug you're having.
 
Just curious: why are you using Theos instead of Xcode? If you were using Xcode you could use its interface builder tool which would get rid of most of the code you've written so far, and I suspect you wouldn't end up with the bug you're having.

I don't have permissions to use Xcode on my school Mac Air, and I don't have a personal personal Mac, so I can't compile anything. So the only thing that's left is Theos.
 
Can't you ask for permission? :p

Your problem is right here:

Code:
webview=[[UIWebView alloc]initWithFrame:self.view.bounds];

You're initialising it with the total area of your view and forgot the navigation bar takes 44 from your total height. Instead of self.view.bounds, use CGRectMake()
 
Can't you ask for permission? :p

Your problem is right here:

Code:
webview=[[UIWebView alloc]initWithFrame:self.view.bounds];

You're initialising it with the total area of your view and forgot the navigation bar takes 44 from your total height. Instead of self.view.bounds, use CGRectMake()

Could you please provide an example?
 
Could you please provide an example?

You did use it to create your navigation bar...... Or did you copy-paste your code? :eek:

Anyway, this should work:

Code:
webview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 44, self.view.frame.size.width, self.view.frame.size.height - 44)];
 
You did use it to create your navigation bar...... Or did you copy-paste your code? :eek:

Anyway, this should work:

Code:
webview=[[UIWebView alloc]initWithFrame:CGRectMake(0, 44, self.view.frame.size.width, self.view.frame.size.height - 44)];

I was using a tutorial, and I am not sure if your solution works, but I was just in the IRC and I was able to fix the issue.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.