Artist_inMood
Artist_inMood

Reputation: 17

calling presentModalViewController within UIView class

my class is UIView, I cant change it to UIViewController because its being called by loadNibNamed within another class.

I know that presentModalViewController sends message to UIViewController, so how i can work on this issue within my UIView class?

This causes crash which is normal:

[self presentModalViewController .... 

Tried this but the called view dosent get pulled:

.h
@class Setting;
@interface SettingProfile : UIView ...
Setting *setting;
@property (nonatomic, retain) Setting *setting;

.m
@synthesize setting;
...
[setting presentModalViewController .... 

i tried this thread but it wasn't much help.

Upvotes: 0

Views: 1411

Answers (1)

RedBlueThing
RedBlueThing

Reputation: 42522

You can't use presentModalViewController on a UIView, this just isn't going to work. You have a couple of options:

  • Refactor so your Setting stuff is in a UIViewController subclass.
  • Add your Setting UIView subclass as a subview of your current view controller view. Animate the view so that it pops up like the presentModal animation.

Seems like you aren't keen on the first option, so to do the second you will need to:

  • Set the frame on your Setting UIView to be offscreen (off the bottom).
  • Start an animation block.
  • Add the Setting view as a subview of your main view controller view.
  • Set the frame to be on screen (so the animation block will move the view from below the bottom screen edge up onto the screen).
  • Commit the animation block.

Upvotes: 2

Related Questions