我有一个UITableView,它作为子视图添加到视图中.选择一行时,将出现一个新视图pushViewController:,用户可以选择按后退按钮返回UITableView,但仍然选中该单元格.
当视图出现时,有没有办法取消选择?
我已经读过我应该使用以下代码,但我无法使其正常工作.没有错误,没有警告,没有任何错误.
[tableProgram deselectRowAtIndexPath:[tableProgram indexPathForSelectedRow] animated:NO];
我遇到了问题popViewController.
我pushViewController用来去OrdersFormViewController
OrdersFormViewController *ordersFormViewController = [[OrdersFormViewController alloc] initWithNibName:@"OrdersFormViewController" bundle:nil];
[self.navigationController pushViewController:ordersFormViewController animated:YES];
[ordersFormViewController release];
Run Code Online (Sandbox Code Playgroud)
从OrdersFormViewController我显示UIAlertView viewDidLoad并调用,popViewController但这不起作用.
UIAlertView* alertView = [[UIAlertView alloc]
initWithTitle:@"Error"
message:@"Error"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
[alertView release];
[self.navigationController popViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)
视图不会从navigationController中"弹出",但是当按下导航栏中的标准后退按钮时,只会更改导航栏而不是实际视图.
有谁知道为什么会这样?
我有一个NSURLConnection,我每次-(void)viewWillAppear:animated都调用它(这只是现在,它仅用于测试)
我是这样做的
receivedData = [[NSMutableData data] retain];
NSString *urlString = @"<URL hidden>";
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestReturnCacheDataElseLoad timeoutInterval:30.0];
[NSURLConnection connectionWithRequest:request delegate:self];
Run Code Online (Sandbox Code Playgroud)
然后我有这三个委托方法:
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[receivedData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *returnString = [[NSString alloc] initWithData:receivedData encoding:NSUTF8StringEncoding];
usersPhotos = [[NSMutableArray alloc] initWithArray:[[returnString JSONValue] objectForKey:@"data"]];
[self loadAnnotations];
NSLog(@"%@", returnString);
[returnString release];
}
- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
[self loadAnnotations];
}
Run Code Online (Sandbox Code Playgroud)
即使我确定returnString应该改变(我可以访问该网站urlString并确认它已经改变)它总是一样的.
就好像它重用了从第一个连接中检索的数据.
有人知道为什么吗?
我编写了一个自定义 UIGestureRecognizer,它可以用一根手指处理旋转。它的设计工作方式与 Apple 的 UIRotationGestureRecognizer 完全相同,并返回相同的值。
现在,我想实现速度,但我无法弄清楚苹果如何定义和计算手势识别器的速度。有谁知道 Apple 如何在 UIRotationGestureRecognizer 中实现此功能?
Facebook最近改变了他们的Graph API以要求访问令牌.因此,我很快创建了一个Facebook应用程序,以便能够检索访问令牌,使用类似于下面的URL,生成我的访问令牌并在我的iPhone应用程序中实现令牌.最近我一直在想我是否做错了什么.每当我的应用程序的用户从Graph API检索数据时,我是否应该请求访问令牌?我开始怀疑访问令牌是否对每个用户或仅对Facebook应用程序是唯一的.
我是否可以将访问令牌硬编码到我的应用程序中,或者每当我需要通过Graph API检索数据时,是否应该在下面的URL上发出请求?
我正在使用以下URL生成访问令牌:
我有一个表格视图,其中细胞是子类.在子类中,我调用了UIView的子类.我已实现tableView:heightForRowAtIndexPath:并希望在我的子类中检索此高度以设置我的子类UIView的实例的高度.
有没有办法做到这一点?
我尝试过使用self.bounds.size.height,self.contentView.frame.size.height但这些都没有给出正确的高度.
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
textCellView = [[TextCellView alloc] initWithFrame:CGRectMake(0, 0, self.bounds.size.width, self.bounds.size.height)];
[[self contentView] addSubview:textCellView];
}
return self;
}
Run Code Online (Sandbox Code Playgroud) 我有一个webview,我想从中消除弹性.就像现在一样,当滚动小于webview的页面时,它会产生弹性效果,显示下面的背景.我想删除它.
我尝试过以下但没有成功.它找到WebDynamicScrollBarsView但设置弹性,不会改变任何东西.
- (void)awakeFromNib
{
NSScrollView *scrollView = [self findScrollViewInSubviews:self.subviews];
scrollView.horizontalScrollElasticity = NSScrollElasticityNone;
scrollView.verticalScrollElasticity = NSScrollElasticityNone;
}
- (NSScrollView *)findScrollViewInSubviews:(NSArray *)subviews
{
for (NSView *view in subviews)
{
if ([view isKindOfClass:[NSScrollView class]])
return (NSScrollView *) view;
else
return [self findScrollViewInSubviews:view.subviews];
}
return nil;
}
Run Code Online (Sandbox Code Playgroud)
有谁知道如何从webview中消除弹性效果?
我的应用程序仅支持纵向方向,但我有网页视图,其中我显示YouTube视频,当这个视频全屏播放时,我希望播放器能够进入风景.我如何仅支持视频的横向?
此外,我使用外观API在整个应用程序中设置导航栏的样式和栏按钮项.这也适用于电影播放器.如何在应用程序的其他部分中使用外观API时如何使用电影播放器的默认布局?
在viewDidLoad中,我以编程方式创建了26个UILabel(字母表中每个字母一个),我将字母表中的字母放入每个标签中(第一个中的A,第二个中的B ......).
后来我想找到一个特定的标签(比如,包含字母"F"的标签).我知道我想要找到的字母及其在字母表中的索引(因此对于F,我知道它的索引是5,因为F是字母表中的第6个字母)
我怎样才能找到这个标签?
当然,我可以制作26个IBOutlets并参考它们,但这看起来很麻烦.
这是我创建标签的方式:
// set letters
letters = [[NSArray alloc] initWithObjects:@"A", @"B", @"C", @"D", @"E", @"F", @"G", @"H", @"I", @"J", @"K", @"L", @"M", @"N", @"O", @"P", @"Q", @"R", @"S", @"T", @"U", @"V", @"W", @"X", @"Y", @"Z", nil];
int positionX = 0;
int positionY = 0;
for(int i = 0; i < [letters count]; i++) {
/* a lot of positioning stuff is here (positionX and positionY is set. I have removed this to make the code look …Run Code Online (Sandbox Code Playgroud) 我希望用户能够在我正在为我正在工作的公司进行的小型聊天中轻松访问表情符号图标.因此,我想制作一个显示可用表情符号图标的面板.要做到这一点,我正在使用NSCollectionView.现在,我需要传递一个字符串,显示在NSTextField.该字符串必须包含一个表情符号图标.
我无法弄清楚如何在字符串中以unicode编写此表情符号图标.我尝试过的所有东西都只显示一个奇怪的符号而不是图标.
谁能告诉我,我怎么能把一个表情符号图标放进去NSString?
在我提出的另一个问题中,我已经开始更多地与代表合作.现在,我已经调用了一个UIViewController ProfileViewController,我希望从Facebook加载News Feed.我也有NSObject的子类调用FBFeed.此子类加载Facebook News Feed并应将其传递回视图控制器.我对Facebook的所有请求都是通过一个名为的单身命令发送的FBRequestWrapper(在这种情况下)应该将结果传递给FBFeed.
我呼吁getFBRequestWithGraphPath:andDelegate:在FBRequestWrapper其中将调用Facebook的iOS版SDK的方法,这需要委托作为参数.如果我放入self(这将是FBRequestWrapper)它工作得很好.如果我放入_delegate(这是一个实例FBFeed)应用程序崩溃了EXC_BAD_ACCESS.
我有理论为什么它会崩溃.我读过这个
@property (nonatomic, retain) id <FBFeedDelegate> delegate;
Run Code Online (Sandbox Code Playgroud)
应该
@property (nonatomic, assign) id <FBFeedDelegate> delegate;
Run Code Online (Sandbox Code Playgroud)
但是这样做时我收到以下错误:
对于unsafe_unretained属性'delegate'的现有ivar'委托'必须是__unsafe_unretained
此外,我不知道是否足以使应用程序崩溃.
这是我的代码.
ProfileViewController.h
#import <UIKit/UIKit.h>
#import "FeedTableView.h"
#import "FBFeed.h"
@interface ProfileViewController : UIViewController <FBFeedDelegate>
{
FeedTableView *tableView;
}
- (void)loadFeed;
@end
Run Code Online (Sandbox Code Playgroud)
ProfileViewController.m
@implementation ProfileViewController
- (void)loadFeed
{
FBFeed *feed = [[FBFeed alloc] init];
[feed loadNewsFeedWithDelegate:self];
}
#pragma mark - …Run Code Online (Sandbox Code Playgroud) iphone ×9
sdk ×5
cocoa ×2
macos ×2
objective-c ×2
uitableview ×2
asynchronous ×1
cell ×1
cocoa-touch ×1
connection ×1
delegates ×1
emoji ×1
facebook ×1
graph ×1
height ×1
retain ×1
row ×1
subclass ×1
token ×1
uiappearance ×1
uilabel ×1
uiwebview ×1
velocity ×1
webview ×1