- 博客(34)
- 收藏
- 关注
原创 ios UITableView去掉上面的空白
//----------这三行可消除tableview空白----------- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{ return 0;}-(UIView *)tableView:(UITableView *)tableView viewForH
2018-04-09 10:18:13 595
原创 json解析
#import "ViewController.h"#import "JSONKit.h"#import "SBJsonParser.h"@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>{ UITableView *_table; NSMutableDictionary *_dic;}
2018-01-27 11:01:57 206
原创 新闻联动demo
SGPagingView是第三方,可以使用cocoapods或者自己去github去找包AppDelegate.h无AppDelegate.m#import "AppDelegate.h"#import "ViewController.h"@interface AppDelegate ()@end@implementation AppDelegate- (BOOL)application:(U
2018-01-18 11:42:21 388
原创 ios饼图
AppDelegate默认ViewController.h默认ViewController.m#import "ViewController.h"#import "KMView.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad { [super viewDidLoad];
2017-12-28 14:21:55 206
转载 iOS中分段控制器与UIScrollView结合使用
AppDelegate.h//默认AppDelegate.m// AppDelegate.m#import "AppDelegate.h"#import "ViewController.h"@interface AppDelegate ()@end@implementation AppDelegate- (BOOL)application:(UIApplication *)applicati
2017-12-28 14:10:53 172
原创 分段控制器(UISegmentedControl)的使用
MYTableViewCell 继承于UITableViewCellViewController.m//ViewController.m#import "ViewController.h"#import "MYTableViewCell.h"@interface ViewController ()<UITableViewDelegate,UITableViewDataSource>{ /
2017-12-28 14:02:12 531
原创 在表格的第一个分区添加轮播图
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ UITableViewCell *cell=nil; cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyl
2017-12-27 14:48:24 239
转载 音乐播放
Podfile# Uncomment the next line to define a global platform for your project# platform :ios, '9.0'target 'SCMusic' do # Comment the next line if you're not using Swift and don't want to use
2017-12-21 14:24:31 682
原创 解析
ShopModel.h#import <Foundation/Foundation.h>@interface ShopModel : NSObject//商品名称@property(nonatomic,strong)NSString *name;//商品价格@property(nonatomic,strong)NSString *price;//商品图片@property(nonatom
2017-12-21 13:35:35 129
原创 MAP
// // ViewController.m // 地图锚点 // // Created by 杜建军 on 2017/12/14. // Copyright © 2017年 杜建军. All rights reserved. //import “ViewController.h”import import pragma mark –手势回调(void) longPress:(
2017-12-14 09:06:43 166
原创 BookManager(ios)
//需要创建的类: AddViewController:继承于UIViewController (xib) UpViewController:继承于UIViewController(xib) Book:继承于NSObject FMDataBaseC:继承于NSObject 需要导入的第三方:MJRefresh(刷新):由于需要通过刷新添加数据 //最终效果通过表格展示AppDeleg
2017-12-10 20:08:55 175
原创 字符串(NSString)
//创建字符串 //第一种 NSString *str1=@"qwertyuiop"; NSLog(@"内容:%@ 地址:%p",str1,str1); NSString *str2=@"年后"; NSLog(@"内容:%@ 地址:%p",str2,str2 ); //&
2017-12-08 08:53:14 142
原创 字典(基本)
//字典的两种方法 //1. NSDictionary *dic=[[NSDictionary alloc]initWithObjectsAndKeys:@”123”,@”456”,@”789”,@”666”,@”e”,@”w”, nil]; NSLog(@”%@”,dic); //2.//注意这里和数组不同,是用的大括号 NSDictionary
2017-12-08 08:52:04 177
原创 数组(基本)
NSMutableArray *array=[[NSMutableArray alloc]init]; BOOL isRight=YES; [array addObject:[NSNumber numberWithBool:isRight]]; NSLog(@"%@",array); // 创建有1个元素的数组 NSArray *array1=[NSArray
2017-12-08 08:50:59 269
转载 通过UISlider改变图片透明度,并且通过UISwitch控制UISlider
//定义变量{ UISwitch *switc; UISlider *slide; UIImageView *imgView;}//在viewDidLoad中实现self.view.backgroundColor = [UIColor whiteColor]; self.title = @"改变图片透明度"; switc = [[UISwitch all
2017-12-05 11:13:58 331
转载 通过UISlider改变图片的透明度(Swift)
//ViewController.swiftimport UIKit //通过滑块改变图片透明度 class ViewController: UIViewController { //图片 @IBOutlet weak var image1: UIImageView! //UISlider @IBAction func slider1(_ sender: UISl
2017-12-05 08:54:56 907
原创 手机号码归属地查询
只需在 ##ViewController.m##中实现以下代码,分为get和post请求#import "ViewController.h"//服务器连接地址#define TEST_URL @"http://ws.webxml.com.cn/WebServices/MobileCodeWS.asmx/getMobileCodeInfo?mobileCode=%@&userID="#defin
2017-11-29 09:05:51 761
原创 UILabel的基本使用
本文引荐别人代码UILabel *label=[[UILabel alloc]initWithFrame:CGRectMake(20, 40, 100, 50)]; //设置背景色 label.backgroundColor=[UIColor redColor]; //设置tag label.tag=99; label.text=@"你好"; labe
2017-11-28 10:17:38 166
原创 UIButton的使用
本篇引荐别人的代码 UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];#pragma mark------设置位置和使能------- //设置大小位置 [button setFrame:CGRectMake(16, 30, 200, 200)]; //设置中心点 [button setCe
2017-11-28 10:15:01 187
原创 ios模仿微信的"我"界面的demo
微信//首先做了一个标签控制器//其次在MyViewController.h中实现"我"## AppDelegate.h ###import <UIKit/UIKit.h>#import "ViewController.h"@interface AppDelegate : UIResponder <UIApplicationDelegate>@property (strong, nonat
2017-11-22 18:03:28 1702
原创 模仿微信的"我"界面的demo
微信//首先做了一个标签控制器//其次在MyViewController.h中实现"我"## AppDelegate.h ###import <UIKit/UIKit.h>#import "ViewController.h"@interface AppDelegate : UIResponder <UIApplicationDelegate>@property (strong, nonat
2017-11-22 18:03:06 282
原创 利用第三方做抽屉式图
通过导航栏左按钮触发抽屉式图//第三方的名字为RESideMenu//1.创建控制器:LeftViewController /2./主视图控制器中的代码为://**ViewController**- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view,
2017-11-16 08:44:36 198
原创 模仿共享单车
//AppDelegate.h#import <UIKit/UIKit.h>#import <CoreData/CoreData.h>#import "RESideMenu.h" //抽屉视图第三方@interface AppDelegate : UIResponder <UIApplicationDelegate>@property(strong,nonatomic)RESideMenu
2017-11-05 23:06:22 529
原创 swift方法实现查看1234能组成多少不同的三位数
“`编写一个程序,查看1、2、3、4四个数字,能组成多少个互不相同且无重复数字的三位数?都是多少?var sum1 = 0 //定义变量用于记录个数for hudder in 1…4 { //百位 for ten in 1…4 { //十位 for num in 1…4 { //个位 if hudder != ten && hudder
2017-10-25 10:48:03 630
原创 Swift字符串大小写互换
func changeCharcter (chNum:Character) -> Character { //将字符转成整数 var chStr = String(chNum) //将字符转成字符串 var num:UInt32 = 0 //用于接受字符整数值的变量 for item in chStr.unicodeScalars { num =
2017-10-25 10:42:55 1035
原创 打印出所有的“水仙花数”,所谓“水仙花数”是指一个三位数,其各位数字立方和等于该数本身。 例如:153是一个“水仙花数”,因为153=1的三次方+5的三次方+3的三次方
var i = 100while i < 999{ var c = i / 100 //百位 var b = (i / 10) - (c * 10) //十位 var a = i % 10 //个位 var abc = a*a*a + b*b*b + c*c*c //立方之和 if abc == i { print("水仙花三位数:\(
2017-10-24 19:38:37 892
原创 古典问题:有一对兔子,从出生后第3个月起每个月都生一对兔子,小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?
func sum(x:Int) -> Int { if x <= 2 { return 1 } else{ //计算兔子的个数 return sum(x: x - 1) + sum(x: x - 2); }}for month in 1...10 { print("\(month):\(sum(x: month))")}
2017-10-24 19:30:23 285
原创 Swift表示分数
class Fraction { var numweator = 0 //分子 var denomator = 0 //分母 static func getMaxYue(num:Int,deno:Int) -> Int { guard num != 0 && deno != 0 else { return -1 }
2017-10-24 19:28:45 403
原创 编写一个程序,求1! + 2! + 3! + 4!的和 要求:使用嵌套定义函数实现
func getSum(number: Int) -> Int { //求某个数阶乘的结果 func getFactorIal(num: Int) -> Int { var sum = 1 for _ in 1...num { sum += 1 } return sum } var
2017-10-24 19:26:06 5490
原创 编写一个程序,能交换两个变量的数值 例如: 变量a值为20,变量b值为30,调用函数后,a的值变为30,b的值变为20
func swap(a: inout Int , b:inout Int){ //交换数值 let temp = a a = b b = temp } var x = 20 , y = 30 swap(a:&x , b:&y) //打印结果 print(x,y)
2017-10-24 19:24:22 4379
原创 编写一个程序,要求接收一个数字,程序会将这个数字以二进制方式打印,例如:数字10 , 以1010的方式打印出来
func binaryPrintIntNumber(num : Int) { var remainderArr:[Int] = [] //int数组,存储余数 var quotient:Int = num //表示商的变量,初始值是num while quotient > 0 { //商的值是0 let remainderNum = quotient %
2017-10-24 19:19:12 1139
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人