Weird error with UIActionSheet

Discussion in 'iOS Development' started by cryptohax, Sep 27, 2009.

  1. cryptohax

    cryptohax Banned

    Joined:
    Sep 13, 2009
    Messages:
    44
    Likes Received:
    0
    Device:
    2G iPod touch
    [OBJC]
    #import "FastBrowserAppDelegate.h"


    @implementation FastBrowserAppDelegate

    @synthesize window;
    @synthesize webView;
    @synthesize addressBar;

    -(IBAction)gotoAddress

    Please Register or Log in to view images

    id) sender {
    NSURL *url = [NSURL URLWithString:[addressBar text]];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];
    [addressBar resignFirstResponder];

    }

    -(IBAction)pushActionSheet; {
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle

    Please Register or Log in to view images

    "Notice" delegate:self cancelButtonTitle

    Please Register or Log in to view images

    "Cancel" destructiveButtonTitle

    Please Register or Log in to view images

    "Okay" otherButtonTitles:nil];
    [actionSheet showInView:self.view];
    [actionSheet release];
    }



    - (void)applicationDidFinishLaunching

    Please Register or Log in to view images

    UIApplication *)application {

    addressBar.delegate = self;

    NSLog(@"didfinishlaunching");

    // Override point for customization after application launch
    [window makeKeyAndVisible];

    [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector

    Please Register or Log in to view images

    selector(loadURL) userInfo:nil repeats:NO];
    }

    - (void)loadURL {
    NSLog(@"SDFSDF");
    NSURL *url = [NSURL URLWithString:[NSString stringWithFormat

    Please Register or Log in to view images

    "http://google.com"]];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [webView loadRequest:requestObj];
    }

    -(IBAction) goBack

    Please Register or Log in to view images

    id)sender {
    [webView goBack];
    }

    -(IBAction) goForward

    Please Register or Log in to view images

    id)sender {
    [webView goForward];
    }

    - (BOOL)webView

    Please Register or Log in to view images

    UIWebView*)webView shouldStartLoadWithRequest

    Please Register or Log in to view images

    NSURLRequest*)request navigationType

    Please Register or Log in to view images

    UIWebViewNavigationType)navigationType {

    if (navigationType == UIWebViewNavigationTypeLinkClicked) {
    NSURL *URL = [request URL];
    if ([[URL scheme] isEqualToString

    Please Register or Log in to view images

    "http://google.com"]) {
    [addressBar setText:[URL absoluteString]];
    [self gotoAddress:nil];
    }
    return NO;
    }
    return YES;
    }


    - (BOOL)textFieldShouldReturn

    Please Register or Log in to view images

    UITextField *)textField {
    NSString *urlAddress = addressBar.text;
    NSURL *url = [NSURL URLWithString:urlAddress];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    [webView loadRequest:requestObj];
    [addressBar setText:urlAddress];
    [addressBar resignFirstResponder];

    return YES;
    }

    @end
    [/OBJC]

    Anyone know why I'm getting this error?

  2. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    As far as I can see you're not using MVC, I think you're just putting a UIWebView on top of a UIWindow, that is why there is no view.

    I could be wrong though....
  3. cryptohax

    cryptohax Banned

    Joined:
    Sep 13, 2009
    Messages:
    44
    Likes Received:
    0
    Device:
    2G iPod touch
    So should it be the UIWebView on top of a UIView?

    EDIT: NEVERMIND: FIXED IT

    Please Register or Log in to view images

  4. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
    I'd recommend creating a UIViewController subclass that obviously controls a UIView, which means all your code isn't in your App delegate.....
  5. cryptohax

    cryptohax Banned

    Joined:
    Sep 13, 2009
    Messages:
    44
    Likes Received:
    0
    Device:
    2G iPod touch
    I fixed it. I just made it self.window

    Please Register or Log in to view images

  6. Axis

    Axis Super Moderator Staff Member

    Joined:
    Dec 2, 2007
    Messages:
    6,288
    Likes Received:
    133
    Device:
    iPhone 4S (White)
    Your application delegate inherits solely from NSObject, and conforms to the UIApplicationDelegate protocol, so obviously, there is not a view property. (unless you've added such a property, which wouldn't make any sense).

    Think about what you tried to do. The error message should be explanatory enough, but it looks like you watched a video tutorial of some sort and threw it in your project without thinking. If you read the docs, you'd know that the [actionSheet showInView:] takes one parameter: a UIView subclass.

    Do you know what the 'self' keyword does?

    EDIT:
    You need to actually understand what your problem was.
  7. Chicken

    Chicken Retired Moderator

    Joined:
    Feb 17, 2008
    Messages:
    2,494
    Likes Received:
    7
    Device:
    iPhone 5S
  8. cryptohax

    cryptohax Banned

    Joined:
    Sep 13, 2009
    Messages:
    44
    Likes Received:
    0
    Device:
    2G iPod touch
    Alright well I have a question that is unrelated to what I said above. So now that my UIActionSheet is working, how do I make other buttons link to certain url's? For example, I want one button to initiate composing new mail. I know the url is @"mailto" but I'm not sure how to hook that up to a button on the action sheet. Thanks!
  9. Axis

    Axis Super Moderator Staff Member

    Joined:
    Dec 2, 2007
    Messages:
    6,288
    Likes Received:
    133
    Device:
    iPhone 4S (White)
  10. SkylarEC

    SkylarEC Super Moderator Emeritus Staff Member

    Joined:
    Sep 19, 2007
    Messages:
    6,642
    Likes Received:
    129
    Please delete everyting that you have done. Read about MVC, then start over.

    http://en.wikipedia.org/wiki/Model–view–controller
    http://developer.apple.com/mac/library/documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html
    http://developer.apple.com/mac/libr...s.html#//apple_ref/doc/uid/TP40002974-CH6-SW1
    http://developer.apple.com/mac/libr....html#//apple_ref/doc/uid/TP40002974-CH6-SW23

    EDIT:
    In other words, you're going to ignore what we're telling you about MVC and are going to continue to move ahead anyway? That is a horrible idea, and your app will fail.

Share This Page