UIkit 框架

本文主要介绍了iOS中的UIKit框架,包括UIAcceleration、UIAccessibilityElement、UIBarItem、UIColor、UIDevice等核心组件的使用,以及如何处理触摸事件、本地通知、区域索引排序等。还涉及了UIPrintInteractionController的打印功能以及UIDocumentInteractionController的文档交互操作。
摘要由CSDN通过智能技术生成




NSObject

—————————————————————————————————————————

—————————————————————————————————————————

1.   UIAcceleration

2. UIAccelerometer  加速计(iOS2 ~ iOS5)

/* UIAcceleration and UIAccelerometer are deprecated as of iOS 5.0. These classes have been replaced by the Core Motion framework.*/


3. UIAccessibilityElement

/**  UIAcceleration /UIAccelerometer /UIAccessibilityElement

        UIAccessibility 非正式协议,提供关于UI元素的辅助功能信息, 

            UIKit里的所有标准视图和控件都是实现了UIAccessibility协议,所有应用默认是可以被肢体障碍者使用的。 可做一些细微调整,不必全部重新实现。

        开启辅助功能

        VoiceOver 读屏

     */


4. UIBarItem

5. UIColor


6.  UIDevice

//testtesttest.................

    // 设备信息

    UIDevice *device = [UIDevice currentDevice];

    DLog(@"name = %@,  \n, model = %@, \n, localizedModel = %@, \n, systemName = %@, \n, systemVersion = %@, \n ", device.name, device.model, device.localizedModel, device.systemName, device.systemVersion);

    DLog(@"orientation = %zd", device.orientation); // home button

    DLog(@"generatesDeviceOrientationNotifications = %d", device.generatesDeviceOrientationNotifications); //

    DLog(@"batteryState = %zd", device.batteryState); // 电池的状态

    DLog(@"batteryLevel = %f", device.batteryLevel);

    

    // 设备标识

    DLog(@"identifierForVendor = %@", device.identifierForVendor.UUIDString); // 相同的一个程序里面-相同的vindor-相同的设备---> 值相同, 卸载重装会被重置

//    DLog(@"OpenUDID = %@", [OpenUDID value]);

    DLog(@"advertisingIdentifier = %@", [[[ASIdentifierManager sharedManager] advertisingIdentifier] UUIDString]); //#import <AdSupport/AdSupport.h>

    

    DLog(@"userInterfaceIdiom = %zd, \n   UI_USER_INTERFACE_IDIOM = %zd", device.userInterfaceIdiom, UI_USER_INTERFACE_IDIOM()); // iPhone iPad TV  carPlay

    

    

    /**

     模拟器 iPhone SE - iOS 10.0(14A345) 输出 :

       name = weiphoneiMac (2),

     , model = iPhone,

     , localizedModel = iPhone,

     , systemName = iPhone OS,

     , systemVersion = 10.0,

       orientation = 1

       generatesDeviceOrientationNotifications = 1  //UIDeviceOrientationPortrait, home button on the bottom

       batteryState = 0

       batteryLevel = -1.000000

     

       identifierForVendor = D90E4491-BCE7-48D4-82C1-AB372755E83D

       advertisingIdentifier = DC56A219-6AC8-436F-9952-6144EA46AED5

     */

//testtesttest.................



7. UIEvent 事件


- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event

{

    // 触摸事件:通过触摸、手势进行触发,例如手指点击、缩放

}

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

    // 运动事件:通过加速器进行触发(例如手机晃动)

}

- (void)remoteControlReceivedWithEvent:(UIEvent *)event

{

    // 远程遥控事件:远程控制事件通过其他远程设备触发(例如耳机控制按钮)

}



// iOS摇一摇功能的实现(运动事件的运用)

    [UIApplication sharedApplication].applicationSupportsShakeToEdit = YES; //设置允许摇一摇功能

    [self becomeFirstResponder]; // 并让自己成为第一响应值

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

    // 摇一摇相关方法

    DLog(@"开始摇动。。。。。。");

}


- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

    DLog(@"摇动结束。。。。。。。");

}


- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event

{

    DLog(@"取消摇动。。。。。。");

}

// 音乐远程控制



8. UITouch  触摸

// 1.触摸时,图片移动(实例)

// 2.创建可以拖动的视图



9. UIFont 字体

/**UIFont

     + (nullable UIFont *)fontWithName:(NSString *)fontName size:(CGFloat)fontSize; //设置字体名称,大小

     

     字体集: HelveticaNeue-Light , STHeiti-Light

     iOS9之后:PingFangSC-Medium  PingFangSC-Regular

     

     */


10. UIImage  图片


11. UILocalizedIndexedCollation/UILocalNotification


UILocalizedIndexedCollation 区域索引排序


@class Person;

@interface WFView ()<UITableViewDelegate, UITableViewDataSource>


@property (copy, nonatomic) NSArray *dataSource;


@end


@implementation WFView


- (instancetype)initWithFrame:(CGRect)frame

{

    self = [super initWithFrame:frame];

    if (self) {

        

        [self initView];

    }

    return self;

}


- (void)initView

{

    UITableView *tableView = [[UITableView alloc] initWithFrame:self.bounds style:UITableViewStyleGrouped];

    tableView.delegate = self;

    tableView.dataSource = self;

    [self addSubview:tableView];

    

    

    /** UILocalizedIndexedCollation 区域索引排序

     

     */

    

    NSArray *originalArray = @[@"aaaa", @"aadsd", @"basasf", @"cd", @"fffdfg", @"edfsfs", @"sdffa", @"fhfdhdf", @"lkofw", @"你好", @"什么", @"在吗", @"盲目", @"是吧", @"诶发", @"威锋", @"游戏", @"区域", @"导航栏", @"按钮", @"文本", @"醉了", @"最后", @"还好呢"];

    

    NSMutableArray *personArr = [NSMutableArray arrayWithCapacity:originalArray.count];

    for (NSString *str in originalArray) {

        Person *person = [[Person alloc] initWithName:str];

        [personArr addObject:person];

    }

    

    UILocalizedIndexedCollation *collation = [UILocalizedIndexedCollation currentCollation];

    DLog(@">>>>>>>>>>  collation.sectionTitles = %@", collation.sectionTitles); // A,B,C,D,E,,,,,X,Y,Z,#

    

    //1.获取section标题

    NSArray *sectionTitles = collation.sectionTitles;

    

    //2.构建每个section数组

    NSMutableArray *sectionArray = [NSMutableArray arrayWithCapacity:sectionTitles.count];

    for (int i = 0; i < sectionTitles.count; i++) {

        NSMutableArray *subArr = [NSMutableArray array];

        [sectionArray addObject:subArr];

    }

    

    //3.排序

    //按照将需要排序的对象放入到对应分区数组

    for (Person *person in personArr) {

        NSInteger section = [collation sectionForObject:person collationStringSelector:@selector(name)];

        NSMutableArray *subArr = sectionArray[section];

        

        [subArr addObject:person];

    }

    //分别对分区进行排序

    for (NSMutableArray *subArr in sectionArray) {

        NSArray *sortArr = [collation sortedArrayFromArray:subArr collationStringSelector:@selector(name)];

        [subArr removeAllObjects];

        [subArr addObjectsFromArray:sortArr];

    }

    

    

    //修改数据源

    self.dataSource = [NSArray arrayWithArray:sectionArray];

}


#pragma mark SectionTitles


- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section

{

    if ([self.dataSource[section] count] == 0) {

        return nil;

    }

    

    return [[

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值