-[UIButton view]: unrecognized selector sent to instance

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • -[UIButton view]: unrecognized selector sent to instance

    ich stehe irgendwo auf dem Schlauch, brauch mal einen Klaps...

    Wenn ich meinen Button so aufbaue:

    Quellcode

    1. UIImage *shareImage = [UIImage imageNamed:@"212-action2.png"];
    2. UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
    3. [shareButton setImage:shareImage forState:UIControlStateNormal];
    4. shareButton.showsTouchWhenHighlighted = YES;
    5. shareButton.frame = CGRectMake(0.0, 3.0, 30,30);
    6. [shareButton addTarget:self action:@selector(showPopOverShare:) forControlEvents:UIControlEventTouchUpInside];
    7. UIBarButtonItem *shareButtonItem = [[UIBarButtonItem alloc] initWithCustomView:shareButton];


    kommt ein Absturz: -[UIButton view]: unrecognized selector sent to instance

    baue ich den Button so auf:

    Quellcode

    1. UIBarButtonItem *shareButtonItem = [[UIBarButtonItem alloc]
    2. initWithImage:[UIImage imageNamed:@"212-action2.png"]
    3. style:UIBarButtonItemStylePlain
    4. target:self
    5. action:@selector(showPopOverShare:)];


    funktioniert alles wunderbar (bis auf den look :rolleyes: )

    Warum ist das so? Wo liegt mein Denkfehler?
    Ich habe auch keine Loesung, aber ich bewundere das Problem!
    _____________________________________________________


    Hape42
  • hape42 schrieb:

    ich stehe irgendwo auf dem Schlauch, brauch mal einen Klaps...

    Wenn ich meinen Button so aufbaue:

    Quellcode

    1. UIImage *shareImage = [UIImage imageNamed:@"212-action2.png"];
    2. UIButton *shareButton = [UIButton buttonWithType:UIButtonTypeCustom];
    3. [shareButton setImage:shareImage forState:UIControlStateNormal];
    4. shareButton.showsTouchWhenHighlighted = YES;
    5. shareButton.frame = CGRectMake(0.0, 3.0, 30,30);
    6. [shareButton addTarget:self action:@selector(showPopOverShare:) forControlEvents:UIControlEventTouchUpInside];
    7. UIBarButtonItem *shareButtonItem = [[UIBarButtonItem alloc] initWithCustomView:shareButton];


    kommt ein Absturz: -[UIButton view]: unrecognized selector sent to instance

    baue ich den Button so auf:

    Quellcode

    1. UIBarButtonItem *shareButtonItem = [[UIBarButtonItem alloc]
    2. initWithImage:[UIImage imageNamed:@"212-action2.png"]
    3. style:UIBarButtonItemStylePlain
    4. target:self
    5. action:@selector(showPopOverShare:)];


    Ich glaube dem "shareButtonItem" aus Beispiel 1 fehlt doch noch Target und Action ?
  • Quellcode

    1. - (IBAction)showPopOverShare:(id)sender
    2. {
    3. NSLog(@"hier bin ich ");
    4. [self dismissAllpopOvers];
    5. UIPopoverController *tmpPopoverController = [[UIPopoverController alloc] initWithContentViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"SMShare"]];
    6. self.myPopoverController = tmpPopoverController;
    7. [self.myPopoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
    8. }


    Im debugger kann ich bis in den PopOverController laufen

    Da steht noch nicht viel drin:

    Quellcode

    1. #import "SMShareViewController.h"
    2. @interface SMShareViewController ()
    3. @end
    4. @implementation SMShareViewController
    5. - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    6. {
    7. self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    8. if (self) {
    9. // Custom initialization
    10. }
    11. return self;
    12. }
    13. - (void)viewDidLoad
    14. {
    15. [super viewDidLoad];
    16. // Do any additional setup after loading the view.
    17. }
    18. - (void)didReceiveMemoryWarning
    19. {
    20. [super didReceiveMemoryWarning];
    21. // Dispose of any resources that can be recreated.
    22. }
    23. - (IBAction)shareFacebook:(id)sender {
    24. }
    25. @end
    Alles anzeigen


    kann es an

    Quellcode

    1. presentPopoverFromBarButtonItem:sender
    liegen?
    Ich habe auch keine Loesung, aber ich bewundere das Problem!
    _____________________________________________________


    Hape42
  • jo

    er steigt mit dieser Zeile aus:

    Quellcode

    1. [self.myPopoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


    Ich hab mal ein kleines Testprojekt mit nur zwei Buttons gemacht, um alle Seiteneffekte auszuschliessen.

    Da passiert es auch
    der Button ohne subview funktioniert, der andere kracht ????
    Ich habe auch keine Loesung, aber ich bewundere das Problem!
    _____________________________________________________


    Hape42
  • Quellcode

    1. [self.myPopoverController presentPopoverFromRect:[sender bounds ] inView:sender
    2. permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];


    Super!!!
    damit funktioniert jetzt alles wie ich es wollte :D

    Danke nochmals für die Hilfe!
    Ich habe auch keine Loesung, aber ich bewundere das Problem!
    _____________________________________________________


    Hape42