我有一个NavigationController,里面有一个TableView.电视中的单元格有一个"模态"segue,指向TableViewController(Class:Details.h/.m).当我选择单元格时,我按预期将其带到TableViewController.
但是我需要添加以下功能:
1)推到目的地所以我得到一个很好的后退按钮.
2)将所选单元中的各种对象信息传递到目的地TVC.
为此,我执行以下任务:
1)将segue更改为"push"并为其指定标识符"segueToDetails"
2.1)将代码添加到didSelectRowAtIndexPath方法(如下)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"segueToDetails" sender:self];
}
Run Code Online (Sandbox Code Playgroud)
2.2)将代码添加到prepareForSegue方法(如下)
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
NSInteger rowNumber = selectedIndexPath.row;
myObject = (MyObject *) [myArray objectAtIndex:rowNumber];
Details *details = [segue destinationViewController];
details.detailsObject = myObject;
}
Run Code Online (Sandbox Code Playgroud)
2.3)确认对象信息正在传递到目的地我使用NSLog输出一些数据(下面)
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"name: %@", detailsObject.name);
}
Run Code Online (Sandbox Code Playgroud)
现在,当我运行项目并在表格中选择一个单元格时,我会被带到目的地TVC,我看到NSLog的输出很好.我也有一个很好的后退按钮.但等等,当我点击回来时,我有另一个后退按钮!单击该返回按钮然后返回到我最初来自的位置.每次我切换到目标TVC时,调试器窗口都会显示此消息.
2012-01-24 13:55:58.240 MyApp[26875:11603] nested push animation can result in corrupted navigation bar
012-01-24 13:55:58.593 MyApp[26875:11603] Finishing up a navigation transition in an …Run Code Online (Sandbox Code Playgroud) 我正在尝试找到一串文本的物理像素大小.然后,我想使用此大小来设置roundRectButton的长度.然而,我用来获取长度的方法返回CGSize.如何将其转换为CGFloat?或者,也许有人可以建议一种完全不同的方式来实现这一点
这是我目前的代码:
// Note: tagAsString is a string of Tag names (Example "tag1, tag2, tag3")
// Note: Code to set this is not relevant to the question.
// get length of tagsAsString.
CGSize tagStringLength = [tagsAsString sizeWithFont:[UIFont fontWithName:@"Helvetica-Bold" size:13.0] forWidth:100.0 lineBreakMode:UILineBreakModeTailTruncation];
// size button to fit length of string
// Note: spotTags is a roundRectButton
cell.spotTags.frame = CGRectMake(96, 33, tagStringLength, 25);
// set the title of the roundRectButton to the tag string
[cell.spotTags setTitle:tagsAsString forState:UIControlStateNormal];
Run Code Online (Sandbox Code Playgroud)
正如您在上面所看到的,我正在使用CGRectMake方法,该方法将4个参数作为CGFloat.然而,我传入一个导致运行时错误的CGSize.
我怎样才能在twig中模仿这个PHP功能?对于for循环的每次迭代,我需要将数字增加5.下面的PHP代码按预期工作:
for($x=5; $x<=20; $x+=5)
{
echo $x,'<br>';
}
Run Code Online (Sandbox Code Playgroud)
哪个输出:
5 ,10 ,15 ,20 ,
Run Code Online (Sandbox Code Playgroud)
但是,twig中的此代码无法按预期工作.
{% for y in range(0, 20) %}
{{ y + 5 }} ,
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
哪个输出:
5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 15 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25
Run Code Online (Sandbox Code Playgroud)
我也尝试为每次迭代设置y的新值,但这不起作用......
{% for y in range(0, 20) %} …Run Code Online (Sandbox Code Playgroud) 我在我的网站上使用了丰富的代码片段,我在页脚中为它们提供了所有代码,以便它们位于中心位置并且易于访问.我不希望在页面上呈现这些片段周围的文本,因为该信息在网站的其他位置.是否可以通过使用隐藏此文本style="display:none"或谷歌是否会完全忽略丰富的代码段,因为这些字段是隐藏的?
<!-- start rich snippet code -->
<div itemscope itemtype="http://schema.org/LocalBusiness">
<span itemprop="name" style="display:none">My Business Name</span>
<div itemprop="address" itemscope itemtype="http://schema.org/PostalAddress">
<span itemprop="streetAddress" style="display:none">123 Example Street, Suite 456</span>
<span itemprop="addressLocality" style="display:none">Major City</span>
<span itemprop="addressRegion" style="display:none">NY</span>
<span itemprop="postalCode" style="display:none">12345</span>
<span itemprop="addressCountry" style="display:none">US</span>
</div>
<span itemprop="telephone" style="display:none">(123) 456-7890</span>
<a itemprop="URL" style="display:none">http://www.mycompanysite.com/</a>
</div>
<!-- end rich snippet code -->
Run Code Online (Sandbox Code Playgroud)
任何信息将不胜感激!提前致谢!
我正在尝试利用Symfony的身份验证和授权功能,但是我对我的security.yml文件看起来有点困惑.
我希望实现以下目标:
1)路由/和/ join(对每个人都是可用的 - 不需要登录).
2)所有其他路由都需要登录/密码.
3)/ adimin路由应仅限于管理员用户.
4)所有用户都应该针对数据库进行身份验证.
我有第4项想出来(我认为) - 见下文.我不确定这个administrators:词是什么意思.这是否只表示管理员使用User类?应该说users:还是其他什么?
security:
encoders:
MySite\Bundle\Entity\User:
algorithm: sha1
encode_as_base64: false
iterations: 1
providers:
administrators: (??? what doest his mean ???)
entity: { class: MySiteBundle:User }
Run Code Online (Sandbox Code Playgroud)
更重要的是 -
对于第1,2和3项,我不知道该放什么.我在该firewalls:部分和access_control:部分下面有一堆条目然而它只是不起作用或有意义.有人可以发布什么security.yml应该看起来像我想要在数字1 - 3完成的目标?
我正在尝试使用LIKE语句创建查询.以下两个例子都可以使用哪一个更好的方法?有没有比另一个更安全的?或者,表现更好?符合最佳做法的一个?别的什么?只是想知道...另外,也许有一种完全不同的方式来执行我不知道的LIKE操作?
例1:
$em = $this->getDoctrine()->getEntityManager();
$query = $em->createQuery(
'SELECT u.user1lname FROM MySiteMyBundle:User u WHERE u.user1lname LIKE :searchTerm ORDER BY u.user1lname ASC'
)->setParameter('searchTerm', $searchTerm.'%');
$result = $query->getResult();
Run Code Online (Sandbox Code Playgroud)
例2:
$em = $this->getDoctrine()->getEntityManager();
$qb = $em->createQueryBuilder();
$result = $qb->select('n.user1lname')->from('MySite\MyBundle\Entity\User', 'n')
->where($qb->expr()->like('n.user1lname', $qb->expr()->literal($searchTerm.'%')))
->getQuery()
->getResult();
Run Code Online (Sandbox Code Playgroud) 我正在使用CoreLocation并从我的应用程序AppDelegate中启动locationManager.示例代码如下......
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// ...
// start location manager
if([CLLocationManager locationServicesEnabled])
{
myLocationManager_ = [[CLLocationManager alloc] init];
myLocationManager_.delegate = self;
[myLocationManager_ startUpdatingLocation];
}
else
{
// ... rest of code snipped to keep this short
Run Code Online (Sandbox Code Playgroud)
在这种方法中,我们看到更新的位置.
-(void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSString *currentLatitude = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.latitude];
NSLog(@"AppDelegate says: latitude: %@", currentLatitude);
// ... rest of code snipped
Run Code Online (Sandbox Code Playgroud)
现在,在我的应用程序的其他区域中,我需要确定用户当前位置(纬度,经度).我可以结合上面的代码到需要当前位置的ViewControllers但后来我不得不CLLocationManager的多个实例运行(我认为) - 为什么复制此代码?有没有办法,从其他ViewControllers,我可以从AppDelegate获取位置信息?
PS - 我正在使用Xcode 4.3 w/ARC
iphone objective-c core-location cllocationmanager cllocation
尝试为iOS启动模拟器时,我收到以下消息:
peters-mbp-2:hello pz$ cordova emulate ios
Running command: /Users/pz/ss/hello/platforms/ios/cordova/run --emulator
simctl was not found.
Check that you have Xcode 6.x installed:
xcodebuild --versionCheck that you have Xcode 6.x selected:
xcode-select --print-path
Error: /Users/pz/ss/hello/platforms/ios/cordova/run: Command failed with exit code 2
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:139:23)
at emitTwo (events.js:87:13)
at ChildProcess.emit (events.js:172:7)
at maybeClose (internal/child_process.js:817:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
Run Code Online (Sandbox Code Playgroud)
我的Xcode版本很好,版本6.2如下所示:
peters-mbp-2:hello pz$ xcodebuild -version
Xcode 6.2
Build version 6C131e
Run Code Online (Sandbox Code Playgroud)
我相信我的路径没有设置但是我不确定要设置它,当前路径是:
peters-mbp-2:hello pz$ xcode-select --print-path
/Applications/Xcode.app/Contents/Developer
Run Code Online (Sandbox Code Playgroud)
同样,我相信我只需要运行以下命令就可以了,有人知道我应该设置路径吗?
peters-mbp-2:hello pz$ xcode-select -s <some path>
Run Code Online (Sandbox Code Playgroud) 我需要另外一双眼睛看这个。在我的一生中,我认为此参数集没有问题,用于 Dynamo DocumentClient,更新方法 -(此处:https : //docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#update -财产)。
{
TableName: "mygame-dev",
Key: { pk: "09d017aa-cbf7-42ce-be6a-a94ecb58f9a7", sk: "GAME" },
ExpressionAttributeNames: { "#GAMELASTUPDATED": "gameLastUpdated", "#GAMETITLE": "gameTitle" },
ExpressionAttributeValues: { ":gamelastupdated": 1556376010704, ":gametitle": "test title 1" },
UpdateExpression: "SET #GAMELASTUPDATED = :gamelastupdated, #GAMETITLE = :gametitle",
ReturnValues: "ALL_NEW"
};
Run Code Online (Sandbox Code Playgroud)
错误:
ValidationException: ExpressionAttributeNames 只能在使用表达式时指定
有什么想法吗?
这真让我抓狂!
我已成功将照片从相机以及如果从相机胶卷中选择现有照片保存到我的应用程序文档目录中。执行此操作的代码如下。注意,我知道这部分正在工作,因为在模拟器中,我可以浏览至应用程序的Documents文件夹并查看正在保存的文件。
示例“保存”代码:
//Note: code above snipped to keep this part of the question short
case 1:
{
// select from library
NSLog(@"select from camera roll");
if([util_ isPhotoLibraryAvailable])
{
UIImagePickerController *controller = [[UIImagePickerController alloc] init];
controller.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
NSMutableArray *mediaTypes = [[NSMutableArray alloc] init];
if([util_ canUserPickPhotosFromPhotoLibrary])
{
[mediaTypes addObject:(__bridge NSString *)kUTTypeImage];
}
controller.mediaTypes = mediaTypes;
controller.delegate = self;
controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:controller animated:YES];
}
} break;
//code below snipped out
Run Code Online (Sandbox Code Playgroud)
拍摄或选择图像后:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSLog(@"picker returned …Run Code Online (Sandbox Code Playgroud) 是否有适用于Xcode的内置api /代码,允许应用程序检测iphone/ipad/ipod touch中安装的其他社交媒体应用程序以填充共享功能?
我被告知Android有这样的功能,iOS也有吗?
twitter xcode objective-c social-networking facebook-social-plugins