在这里,我有一个页面控件,它工作正常,但点击它不会改变页面,所以请帮助改变页面的功能:
- (void)viewDidLoad {
scrollView=[[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 320, 420)];
scrollView.delegate = self;
[self.scrollView setBackgroundColor:[UIColor whiteColor]];
[scrollView setCanCancelContentTouches:NO];
scrollView.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scrollView.clipsToBounds = YES;
scrollView.scrollEnabled = YES;
[scrollView setShowsHorizontalScrollIndicator:NO];
scrollView.pagingEnabled = YES;
[self.view addSubview:scrollView];
pageControl=[[UIPageControl alloc]initWithFrame:CGRectMake(0, 420, 320, 40)];
[pageControl addTarget:self action:@selector(changepage:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:pageControl];
UIView *blueView = [[UIView alloc] init];
blueView.frame = CGRectMake(0, 0, 640, 480);
blueView.backgroundColor = [UIColor whiteColor];
[scrollView addSubview:blueView];
self.pageControl.numberOfPages = 2;
[scrollView setContentSize:CGSizeMake(640, 0)];
}
-(void)changepage:(id)sender
{
int page = pageControl.currentPage;
if (page < 0)
return; …
Run Code Online (Sandbox Code Playgroud) func drawOnPDF(path: String)
{
// Get existing Pdf reference
let pdf = CGPDFDocumentCreateWithURL(NSURL(fileURLWithPath: path))
// Get page count of pdf, so we can loop through pages and draw them accordingly
let pageCount = CGPDFDocumentGetNumberOfPages(pdf);
// Write to file
UIGraphicsBeginPDFContextToFile(path, CGRectZero, nil)
// Write to data
// var data = NSMutableData()
// UIGraphicsBeginPDFContextToData(data, CGRectZero, nil)
for index in 1...pageCount {
let page = CGPDFDocumentGetPage(pdf, index)
let pageFrame = CGPDFPageGetBoxRect(page, kCGPDFMediaBox)
UIGraphicsBeginPDFPageWithInfo(pageFrame, nil)
var ctx = UIGraphicsGetCurrentContext()
// Draw existing page
CGContextSaveGState(ctx); …
Run Code Online (Sandbox Code Playgroud) 我想在单元格上单击seeMoreBtn后展开单元格大小.
标签和单元格具有不同的长度,但它们是标签大小的约束.
当状态太大时,我添加了一个seeMoreBtn,点击后查看更多剩余文本将在下面显示,然后如何增加标签和单元格大小.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
NSString *text = [items objectAtIndex:[indexPath row]];
CGSize constraint = CGSizeMake(300.0f, 150.0f);
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:14.0f] constrainedToSize:constraint lineBreakMode:NSLineBreakByCharWrapping];
CGFloat height1 = MAX(size.height, 44.0f);
return height1 + (40.0f);
}
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *CellIdentifier = [NSString stringWithFormat:@"Cell-%d",indexPath.row];
cell=[tv dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
int lbltag = 1000;
label=[[UILabel alloc]initWithFrame:CGRectZero];
[label setLineBreakMode:NSLineBreakByWordWrapping];
[label setMinimumScaleFactor:14.0f];
[label setNumberOfLines:0];
[label setFont:[UIFont systemFontOfSize:14.0f]];
NSString *text = [items …
Run Code Online (Sandbox Code Playgroud) 我在失败块中获取json字符串
NSURL *url = [[NSURL alloc] initWithString:@"http://www.vinipost.com/Services/Update/UpdateService.asmx/GetPropSubType?"];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:url];
[AFJSONRequestOperation addAcceptableContentTypes:[NSSet setWithObject:@"text/html"]];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"%@", JSON);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo);
}];
[operation start];
Run Code Online (Sandbox Code Playgroud)
输出:
Request Failed with Error: Error Domain=AFNetworkingErrorDomain Code=-1016 "Expected content type {(
"text/json",
"text/javascript",
"application/json",
"text/html"
)}, got text/plain" UserInfo=0x71521a0 {NSLocalizedRecoverySuggestion=[{"PropTypId":1,"PropCatId":1,"PropTyp":"Flat/ Condo"}.......**
Run Code Online (Sandbox Code Playgroud) ios ×4
iphone ×3
objective-c ×2
afnetworking ×1
json ×1
swift ×1
uiscrollview ×1
uitableview ×1