我有一个UITableview我正在显示一些任务,每行都有一个复选框,用于标记任务是否完成.
我想在用户点击复选框时切换复选标记,并在用户点击该行时切换到详细视图.后者很容易,只需使用即可
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
但是,我想分离选择区域,仅在选中时切换复选框accessoryview,并仅在选择其余单元格时进入详细视图.如果我在UIbutton里面添加一个accessoryview,用户将选择行和UIButton他们只想点击复选框,对吗?
此外,如果用户只是通过拖动来滚动浏览tableview accessoryview怎么办?这不会触发UIButtonTouchUp 上的动作吗?
任何人对如何做到这一点都有任何想法?谢谢你的时间!
这里是一个ViewControllerA推一个ViewControllerB,并在ViewControllerB该leftBarButtonItem设置如下:
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backBtnClicked:)];
Run Code Online (Sandbox Code Playgroud)
设置后leftBarButtonItem,后退滑动手势不起作用.是否可以保持滑动手势?
我有一个像"这是一个好苹果"的字符串.在我的UIlabel上显示.我想用不同的字体设置"好"这个词.看起来像"这是一个好苹果".
我在视图出现时开始更新当前位置,并在每次locationManager:didUpdateLocations:调用时停止更新位置.但为什么locationManager:didUpdateLocations:总是多次被召唤?我错过了什么?
#import "ViewController.h"
@interface ViewController (){
CLLocationManager *locationManager; // location manager for current location
}
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
[self startUpdatingCurrentLocation];
}
- (void)startUpdatingCurrentLocation
{
if (!locationManager)
{
locationManager = [[CLLocationManager alloc] init];
[locationManager setDelegate:self];
locationManager.distanceFilter = 10.0f; // we don't need to be any more accurate than 10m
}
[locationManager startUpdatingLocation];
}
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations{
[locationManager stopUpdatingLocation];
}
@end
Run Code Online (Sandbox Code Playgroud) 我们知道它UITextView在iOS 7中更强大,但在这里它表现得更加脆弱.在iOS 6中使用中文输入键盘输入"rr"时,以下代码可正常工作,但在iOS 7中崩溃.
- (void)viewDidLoad
{
[super viewDidLoad];
self.tv = [[UITextView alloc] initWithFrame:CGRectMake(0, 100, 320, 100)];
self.tv.backgroundColor = [UIColor yellowColor];
self.tv.textColor = [UIColor blackColor];
self.tv.editable = YES;
self.tv.delegate = self;
[self.view addSubview:self.tv];
}
-(void)textViewDidChange:(UITextView *)textView{
int maxLength = 2;
if (self.tv.text.length > maxLength) {
NSLog(@"self.tv.text :%@",self.tv.text);
NSLog(@"self.tv.text.length :%d",self.tv.text.length);
NSLog(@"maxLength :%d",maxLength);
self.tv.text = [self.tv.text substringToIndex:maxLength];
}
}
Run Code Online (Sandbox Code Playgroud)
日志如下:
2013-11-13 15:48:16.003 Test2[1388:70b] self.tv.text :r?r
2013-11-13 15:48:16.004 Test2[1388:70b] self.tv.text.length :3
2013-11-13 15:48:16.005 Test2[1388:70b] maxLength :2
2013-11-13 15:48:16.032 Test2[1388:70b] *** Terminating …Run Code Online (Sandbox Code Playgroud) 我需要一个带有核心数据持久性的选项卡式应用程序.当我使用选项卡式应用程序模板创建一个新项目时,我找不到"使用核心数据"复选框.是否可以手动将核心数据添加到使用选项卡式应用程序模板创建的项目中?
在项目摘要中,"支持的界面方向"全部被选中,因为我的应用程序中有一个照片库视图,可以随设备一起旋转.其他观点仅限于肖像.目标设备是iPhone,所有东西在iPhone中都表现良好.但是当它在我的iPad上运行横向模式时,启动和rootView如下:
飞溅景观:

rootview景观:

我期望看起来应该与iPad是纵向模式相同:
飞溅画像:

rootview画像:

rootView是MyNavigationController,一些相关的代码如下:
MyNavigationController.m
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskPortrait;
}
- (BOOL)shouldAutorotate {
return NO;
}
Run Code Online (Sandbox Code Playgroud) 我在Android Studio中创建了一个Hello,World项目来测试使用System.out.println().我相信日志消息应该在控制台中打印,但事实并非如此.我使用Android Studio AI-130.737825和JRE:1.7.0_25.测试代码如下:
package com.example.consoletest;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
System.out.println("please print me in the console");
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
Run Code Online (Sandbox Code Playgroud) 一个UIButton被设置为rightCalloutAccessoryView的MKPinAnnotationView,并且它触发btnClicked:方法.在iOS6中,MKAnnotationView它之间的布局关系rightCalloutAccessoryView可以很容易地用于查找MKPinAnnotationView直通 MKPinAnnotationView *pin = (MKPinAnnotationView *)[[button superview] superview];.但在iOS7中,布局关系不再存在.
- (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation{
...
MKPinAnnotationView *pinView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:tripStartAddrAnnotationIdentifier];
if (!pinView)
{
MKPinAnnotationView *customPinView = [[MKPinAnnotationView alloc]
initWithAnnotation:annotation reuseIdentifier:tripStartAddrAnnotationIdentifier];
customPinView.animatesDrop = NO;
customPinView.canShowCallout = YES;
UIButton* rightButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 32, 32)];
[rightButton setImage:[UIImage imageNamed:@"disclosureUpMap.png"] forState:UIControlStateNormal];
[rightButton setImage:[UIImage imageNamed:@"disclosureDownMap.png"] forState:UIControlStateNormal];
[rightButton addTarget:self
action:@selector(btnClicked:)
forControlEvents:UIControlEventTouchUpInside];
customPinView.rightCalloutAccessoryView = rightButton;
return customPinView;
}
else …Run Code Online (Sandbox Code Playgroud) 当显示带有一些没有换行符的长字符串的段落时,UIWebView字符的大小太小而无法读取,如下图所示.无论如何都要在长字符串中自动添加换行符,如同UILabel?提前致谢!

PS.的UIWebView用于显示电子邮件正文.
ios ×5
iphone ×5
ios7 ×3
objective-c ×3
android ×1
console ×1
core-data ×1
fonts ×1
html5 ×1
ipad ×1
line-breaks ×1
orientation ×1
println ×1
tabbed ×1
uilabel ×1
uitableview ×1
uitextview ×1
uiwebview ×1
xcode ×1