1

私は、すべてのビューでコントロールが必要な iphone アプリケーションを開発しています。

Iphone 開発で Asp.net マスター ページに同等の濃度があるかどうか疑問に思っていましたか?

4

3 に答える 3

1

もちろん、カスタム UIView または UIViewController クラスを使用し、そこからすべてのビューまたはビュー コントローラーをサブビューします。

于 2010-10-19T16:11:42.687 に答える
0

次の手順を使用してそれを達成できます。1. 「UIView」のサブクラスで新しいファイルを作成し、「customButom」という名前を付けます。 2. UIView インターフェイス ファイルを追加して、customButtom.xib という名前を付け、customButtom ファイルを xib にリンクします。3. この後、Utility Panel で UIView のサイズを Freedom に設定します。希望の幅と高さを設定します。この例では、160x50 に設定しました。イベント ハンドルのプロトコル、プロパティ、および IBAction を作成しました。

 //customButton.h
#import<UIKit/UIKit.h>

// createdcustomButtonDelegate protocol 

@protocolcustomButtonDelegate<NSObject>
    -(void)performButtonClicked;
@end


@interfacecustomButton : UIView

    @property(nonatomic,retain)id<customButtonDelegate>delegate;

    -(IBAction)customButtonClicked:(id)sender;

@end

//customButton.m  Implemented properties and button action `

#import"customButton.h"

@implementationcustomButton
   -(id)initWithFrame:(CGRect)frame {
      self = [superinitWithFrame:frame];
      if (self) {
        UIView *buttonView =[[[NSBundlemainBundle]loadNibNamed:@"customButton"owner:selfoptions:nil] objectAtIndex:0];
    [selfaddSubview:buttonView];
    }
    returnself;
}


-(IBAction)customButtonClicked:(id)sender {
    if (self.delegate != nil) {
       [self.delegateperformButtonClicked];
    }
}

@end


// Viewcontroller.h  Import customButton.h file in our view controller and add delegate      `

#import<UIKit/UIKit.h>

#import"customButton.h"

@interfaceViewController : UIViewController<UIAlertViewDelegate,customButtonDelegate>
@end

// Viewcontroller.m file

@interfaceViewController ()
@end

@implementationViewController {
   customButton *buttonView;
}


- (void)viewDidLoad {
    [superviewDidLoad];
    // we can display / set our custom view on specific location on view. just need to provide your desire Frame

   //creating customButton object and added this object to our view. 
   buttonView = [[customButtonalloc]initWithFrame:CGRectMake(80, 465, 160, 50)];
   buttonView.delegate = self;
   [self.viewaddSubview:buttonView];
}


#pragma mark custombutton delegate
-(void)performButtonClicked {
   NSLog(@"Perform whatever you want to");
}
@end
于 2015-08-04T10:57:30.173 に答える
0
1. Create a viewController class as TopViewController and delete already created view first then add a view from IB (drag drop) and connect to File's Owner (view) then set height and width what you want.
2. Create object of  TopViewController like-
  TopViewController *topVC=[[TopViewController alloc] initWithNibName:@"TopViewController" bundle:nil];
  [self.view addSubView:topVC.view];
于 2011-12-15T06:24:44.670 に答える