Giter VIP home page Giter VIP logo

blockui's Introduction

BlockUI

BlockUI主要有两个功能:

  • 扩展UIControl,UIActionSheet,UIAlertView。使用block最为回调,简化调用流程,是代码在逻辑上更通顺。
  • 扩展NSObject,方便对象间通信。

##Author## 张玺

微博:http://weibo.com/zxrex

Home:http://zhangxi.me

##Require##

  • ARC
  • iOS 4.0 or later

##Use## screen

//in first object
    InputViewController *input = [[InputViewController alloc] initWithNibName:@"InputViewController" bundle:nil];
    input.navigationItem.title = @"input";
    
    
    //receive object with default identifier
    [input receiveObject:^(id object) {
        _label.text = object;
        NSLog(@"[default]receive : %@",object);
    }];
    
    //receive object with custom identifier
    [input receiveObject:^(id object) {
         NSLog(@"[inputFinish]receive : %@",object);
    } withIdentifier:@"inputFinish"];

    
    [input handlerEventWithBlock:^(NSString *value1,NSString *value2){
    
        NSLog(@"%@",value1);
        NSLog(@"%@",value2);
    }
                  withIdentifier:@"custom block"];
    
    
    
    [self.navigationController pushViewController:input animated:YES];

//in second object
    //send object use default identifier
    [self sendObject:_textFeild.text];
    
    //send object use custom identifier
    [self sendObject:_textFeild.text
      withIdentifier:@"inputFinish"];
    
    
    void(^block)(NSString *,NSString *) = [self blockForEventWithIdentifier:@"custom block"];;
    
    block(@"I'm the first value",@"I'm the second value");
    
    
//first of all
#import "BlockUI.h"


//UIAlertView
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title"
                                                  message:@"message"
                                                 delegate:self
                                        cancelButtonTitle:@"ok"
                                        otherButtonTitles:nil];
[alert showWithCompletionHandler:^(NSInteger buttonIndex) {
        NSLog(@"button:%d",buttonIndex);
}];


//UIActionSheet
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"title"
                                                      delegate:nil
                                             cancelButtonTitle:@"ok"
                                        destructiveButtonTitle:nil
                                             otherButtonTitles:@"1",@"2", nil];
[action showInView:self.view withCompletionHandler:^(NSInteger buttonIndex) {
    NSLog(@"button:%d",buttonIndex);
}];



//UIButton .etc
UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[button handleControlEvent:UIControlEventTouchUpInside withBlock:^(id sender){
    NSLog(@"in");
}];
[button handleControlEvent:UIControlEventTouchUpOutside withBlock:^(id sender){
    NSLog(@"out");
}];
[button removeHandlerForEvent:UIControlEventTouchUpInside];

UISegmentedControl *seg = [[UISegmentedControl alloc] initWithItems:@[@"1",@"2",@"3"]];

[seg handleControlEvent:UIControlEventValueChanged withBlock:^(id sender) {
    NSLog(@"%@",sender);
}];

blockui's People

Contributors

zhangxigithub avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.