//
// OC2Wax.m
//
//
// Created by muzico on 16/3/26.
//
//
#pragma mark - 目录
/**
创建一个UIViewController对象
创建一个UIButton对象
presentViewController
dismissViewController
MZCKit的使用
mzcSendSelfMessage
*/
#pragma mark - 创建一个UIViewController对象
/***************** 创建一个UIViewController对象 START ******************/
/*****
Wax
****/
waxClass{"ViewController", UIViewController}
function dealloc(self)
self.super:dealloc(self)
end
function init(self)
self.super:init(self)
end
function loadView(self)
self.super:loadView(self)
end
function viewDidLoad(self)
self.super:viewDidLoad(self)
end
function viewWillAppear(self, animated)
self.super:viewWillAppear(self, animated)
end
function viewDidAppear(self, animated)
self.super:viewDidAppear(self, animated)
end
function viewWillDisappear(self, animated)
self.super:viewWillDisappear(self, animated)
end
function viewDidDisappear(self, animated)
self.super:viewDidDisappear(self, animated)
end
/*****
OC
****/
@interface ViewController : UIViewController
@end
@implementation ViewController
- (void) dealloc
{
[super dealloc];
}
- (id) init
{
self = [super init];
if(self) {
}
return self;
}
- (void) loadView
{
[super loadView];
}
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void) viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
@end
/***************** 创建一个UIViewController对象 END ******************/
#pragma mark - 创建一个UIButton对象
/***************** 创建一个按钮 START ******************/
/*****
Wax
****/
self.myButton = UIButton:init()
self.myButton:setBackgroundColor(UIColor:redColor())
self.myButton:setTitle_forState("点击我进入下一页吧!",UIControlStateNormal)
self.myButton:addTarget_action_forControlEvents(self,"pressedButtonToDoSomething:",UIControlEventTouchUpInside)
self.myButton:setFrame(CGRect(10, 300, 320, 40))
self:view():addSubview(self.myButton)
function pressedButtonToDoSomething(self, sender)
//do something
end
/*****
OC
****/
@property(nonatomic,strong) UIButton* myButton;
self.myButton = [[UIButton alloc] init];
[self.myButton setBackgroundColor:[UIColor redColor]];
[self.myButton setTitle:@"点击我进入下一页吧!" forState:UIControlStateNormal];
[self.myButton addTarget:self action:@selector(pressedButtonToDoSomething:) forControlEvents:UIControlEventTouchUpInside];
[self.myButton setFrame:CGRectMake(10, 300, 320, 40)];
[self.view addSubview:self.myButton];
- (void) pressedButtonToDoSomething:(UIButton*) sender
{
//do something
}
/***************** 创建一个按钮 END ******************/
#pragma mark - presentViewController
/***************** presentViewController START ******************/
/*****
Wax
****/
local tempController = SecondController:init()
self:presentViewController_animated_completion(tempController, true, toblock(
function()
//do something
end,{"void","void"}))
/*****
OC
****/
UIViewController* tempViewController = [[UIViewController alloc] init];
[self presentViewController:tempViewController animated:YES completion:^{
//do something
}];
/***************** presentViewController END ******************/
#pragma mark - dismissViewController
/***************** dismissViewController START ******************/
/*****
Wax
****/
self:dismissViewControllerAnimated_completion(true, toblock(
function()
//do something
end,{"void","void"}))
/*****
OC
****/
[self dismissControllerAnimated:YES completion:^{
//do something
}];
/***************** dismissViewController END ******************/
#pragma mark -
#pragma mark - MZCKit的使用
#pragma mark -
#pragma mark mzcSendSelfMessage
/***************** mzcSendSelfMessage END ******************/
/*****
Wax
****/
//在ViewController1
function pressedButtonToDoSomething(self, sender)
local tempController = ViewController2:init()
tempController:mzcReceiveSelfMessage(toblock(
function(object)
tempController:dismissViewControllerAnimated_completion(true, toblock(
function()
//do something
end,{"void","void"}))
end,{"void","id"}))
self:presentViewController_animated_completion(tempController, true, toblock(
function()
//do something
end,{"void","void"}))
end
//在ViewController2
function pressedButtonToDoSomething(self, sender)
self:mzcSendSelfMessage();
end
/*****
OC
****/
//在ViewController1
- (void) pressedButtonToDoSomething:(UIButton*) sender
{
ViewController2* tempController = [[ViewController2 alloc] init];
[tempController mzcReceiveSelfMessage:^(id object) {
[tempController dismissControllerAnimated:YES completion:^{
//do something
}];
}];
[self presentViewController:tempViewController animated:YES completion:^{
//do something
}];
}
//在ViewController2
- (void) pressedButtonToDoSomething:(UIButton*) sender
{
[self mzcSendSelfMessage];
}
/***************** mzcSendSelfMessage START ******************/