IOS开发,从应用跳转到用浏览器打开网页:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.oatos.com/bbs/"]];

用一个Button覆盖整个cell,加入动作

cell.accessoryType = UITableViewCellAccessoryNone;

        UIButton *btn = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, cell.contentView.frame.size.width, 54.0)];
btn.autoresizingMask = UIViewAutoresizingFlexibleWidth;
btn.backgroundColor = COLOR(243.0, 89.0, 31.0, 1.0);
btn.tag = 1003;
NSString *title = nil;
#ifndef appstore
title = NSLocalizedString(@"Pad_setting_exitBtnTitle", nil);
#else
title = NSLocalizedString(@"Pad_setting_logoutBtnTitle", nil);
#endif
[btn setBackgroundImage:[UIImage imageNamed:@"bgBtnLogoutNormal.png"] forState:UIControlStateNormal];
[btn setBackgroundImage:[UIImage imageNamed:@"bgBtnLogoutHover.png"] forState:UIControlStateHighlighted];
[btn setTitle:title forState:UIControlStateNormal]; btn.titleLabel.font = [UIFont boldSystemFontOfSize:20.0];
[btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(loginOuBtnClicked:) forControlEvents:UIControlEventTouchUpInside]; [cell.contentView addSubview:btn];
cell.selectionStyle = UITableViewCellSelectionStyleNone;

经常使用的宏定义

#define IOS_VERSION  [[UIDevice currentDevice] deviceVersion]
#define kDeviceAgent [[UIDevice currentDevice] deviceAgent] #define IsiOS7Later !(IOS_VERSION < 7.0)
#define Is4Inch [OatosUtils is4InchScreen]

#define COLOR(R,G,B,A) [UIColor colorWithRed:R/255.0 green:G/255.0 blue:B/255.0 alpha:A]
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
#define Size(w, h)                          CGSizeMake(w, h)
#define Point(x, y) CGPointMake(x, y)
#define Rect(x, y, w, h) CGRectMake(x, y, w, h)
#define ViewWidth(v) v.frame.size.width
#define ViewHeight(v) (IsiOS7Later ? v.frame.size.height : v.frame.size.height - StatusBarHeight)
#define ViewX(v) v.frame.origin.x
#define ViewY(v) v.frame.origin.y
#define ViewRect(v) Rect(ViewX(v), ViewY(v), ViewWidth(v), ViewHeight(v))
#define SelfViewHeight self.view.bounds.size.height
#define kDeviceScreenH                  [[UIScreen mainScreen] bounds].size.height
#define kDeviceScreenW [[UIScreen mainScreen] bounds].size.width #define kAppMainScreenFrameWidth [[UIScreen mainScreen] applicationFrame].size.width
#define kAppMainScreenFrameHeight [[UIScreen mainScreen] applicationFrame].size.height
#define StatusBarHeight                     [UIApplication sharedApplication].statusBarFrame.size.height

#define kHeightStatusAndNav       (IsiOS7Later ?

64 : 44)    // 状态栏和导航栏的总高度
#define kPadHeightNavForPopView 44 //3.4版本号后開始使用的,重构后机制不一样(跟弹出层布局相关)
#define kStatusBarFix (IsiOS7Later ? 20 : 0) // 状态栏高度
#define kPadHeightStatusAndNav (IsiOS7Later ? 64 : 0) // 状态栏和导航栏的总高度
#define kPadNaviBarHeight (IsiOS7Later ? 54.0f : 0) // pad不含状态栏的导航栏的高度
#define kPadBottomBarHeight 60.0f
#define kPadHeightNav (IsiOS7Later ? 44 : 0)

小结:代码中,尽量不要用写死的数据,不然版本号适配以及以后的优化是非常痛苦的事情。

还实用宏定义能够简化代码。眼下我的理解仅仅有这么多。希望以后对这个掌握的更好。尽管这仅仅是小基础。可是也是一种良好的编程习惯。一个好的開始。

IOS开发,知识点小结,ios开发中经常使用的宏定义总结的更多相关文章

  1. iOS --- 总结Objective-C中经常使用的宏定义(持续更新中)

    将iOS开发中经常使用的宏定义整理例如以下,仅包括Objective-C. 而对于Swift,不能使用宏,则能够定义全局函数或者extension.请參考博客iOS - 总结Swift中经常使用的全局 ...

  2. C中的预编译宏定义

     可以用宏判断是否为ARC环境 #if _has_feature(objc_arc) #else //MRC #endif C中的预编译宏定义 -- 作者: infobillows 来源:网络 在将一 ...

  3. IOS开发中经常使用的宏定义

    ios讨论群1群:135718460 有些时候.我们须要将代码简洁化,这样便于读代码.我们能够将一些不变的东东抽取出来.将变化的东西作为參数. 定义为宏,这样在写的时候就简单多了. 以下例举了一些经常 ...

  4. VC中预处理指令与宏定义详解

    刚接触到MFC编程的人往往会被MFC 向导生成的各种宏定义和预处理指令所吓倒,但是预处理和宏定义又是C语言的一个强大工具.使用它们可以进行简单的源代码控制,版本控制,预警或者完成一些特殊的功能. 一个 ...

  5. 在oc中一些常用的宏定义总结

    1.打印CGRect,Size,Point #define NSLogRect(rect) NSLog(@"%s x:%.4f, y:%.4f, w:%.4f, h:%.4f", ...

  6. linux中offsetof与container_of宏定义

    linux内核中offsetof与container_of的宏定义 #define offsetof(TYPE, MEMBER)    ((size_t) &((TYPE *)0)->M ...

  7. C++ 中 #ifndef, #define, #endif 宏定义

    目的:为了保证包含的内容只被程序(include) 和编译了一次.判断预处理器常量是否已被定义. 预编译将所有头文件(#include"XXX.h")用头文件中的内容来替换,头文件 ...

  8. 内核中likely和unlikely宏定义

    在内核代码中经常会看到unlikely和likely的踪影.他们实际上是定义在 linux/compiler.h 中的两个宏. #define likely(x)    __builtin_expec ...

  9. iOS开发中常用到的宏定义

    1.首次启动判断: #define First_Launched @"firstLaunch" 2.ios7系统判断: #define IsIOS7 ([[[UIDevice cu ...

随机推荐

  1. 算法复习——splay+启发式合并(bzoj2733-永无乡)

    题目: Description 永无乡包含 n 座岛,编号从 1 到 n,每座岛都有自己的独一无二的重要度,按照重要度可 以将这 n 座岛排名,名次用 1 到 n 来表示.某些岛之间由巨大的桥连接,通 ...

  2. 算法复习——树链剖分模板(bzoj1036)

    题目: 题目背景 ZJOI2008 DAY1 T4 题目描述 一棵树上有 n 个节点,编号分别为 1 到 n ,每个节点都有一个权值 w .我们将以下面的形式来要求你对这棵树完成一些操作:I.CHAN ...

  3. P2389 电脑班的裁员 (动态规划)

    题目背景 隔壁的新初一电脑班刚考过一场试,又到了BlingBling的裁员时间,老师把这项工作交给了ZZY来进行.而ZZY最近忙着刷题,就把这重要的任务交(tui)给了你. 题目描述 ZZY有独特的裁 ...

  4. KS求有向图强连通分量模板

    #include<bits/stdc++.h> using namespace std; typedef long long ll; int n,m; ; *maxn; struct no ...

  5. Spoj-BIPCSMR16 Team Building

    To make competitive programmers of BUBT, authority decide to take regular programming contest. To ma ...

  6. Python入门--1--基本中的基本

    一. 1.这是一个面向对面的编程,一种解释性语言. 2.缩进是python的灵魂,使代码变得非常简洁,正确使用冒号“:”,IDLE的       下一行会自动缩进 3.if语句中 python拒绝接受 ...

  7. 使用 ftrace 调试 Linux 内核,第1部分

    ftrace 是 Linux 内核中提供的一种调试工具.使用 ftrace 可以对内核中发生的事情进行跟踪,这在调试 bug 或者分析内核时非常有用.本系列文章对 ftrace 进行了介绍,分为三部分 ...

  8. Laravel 控制器的request

    public function request1(Request $request){ //取值 $name = Request::input('name'); //是否有值 if($request- ...

  9. CMDB资产管理系统的数据表设计

    Server表: asset = models.OneToOneField('Asset') 主机名(hostname) sn号(sn) 制造商(manufacture) 系统(os_platform ...

  10. P3378 堆【模板】 洛谷

    https://www.luogu.org/problem/show?pid=3378 题目描述 如题,初始小根堆为空,我们需要支持以下3种操作: 操作1: 1 x 表示将x插入到堆中 操作2: 2 ...