我有我的故事板的以下设置
NC - > TVC - > VC - > TVC - > VC
我遇到的问题是从TableViewController到ViewController的第一个segue确实有效,第二个没有.两者都配置为推送segue(实际所有转换都以这种方式配置)两个表都是动态填充的.只是第一个工作,第二个不工作.可能是什么问题?segues命名设置,表格单元格有id,选择表格单元格的事件在两种情况下都被触发,但是第二种情况下不准备segue.
提前致谢
我试图建立我的自定义SEGUE,在行为标准推SEGUE相似,但在我的情况下,我想使用自定义按钮屏幕间切换(无标签栏会适合这个应用程序,任何模式赛格瑞是没有好或者) .主屏幕是自定义图形,屏幕是一个地图.用户选择地图上的点,点击完成并返回主屏幕及其坐标.我正在尝试将ViewControllers与自定义segue连接起来.
我在互联网上研究了很多解决方案并找到了一个可以适应的解决方案,但代码分散在ViewControllers和AppDelegate周围(我不确定Apple是否会接受它).我正在尝试将整个代码放到CustomSegue.m/h.成功是部分的,因为使用技术(下面)它会分割到第二个ViewControler,但我无法弄清楚如何解除第二个并回到主屏幕.我尝试了各种技术,但是当我运行它时,编译器会终止带有大量错误的应用程序.在构建和运行之前既没有错误也没有警告.我还尝试使用[self dismissModalViewControllerAnimated:YES]按钮解除它; 或[self dismissViewControllerAnimated:YES completion:nil]; 当我尝试模态segues但我的代码结果不好时,它们会工作.
有没有人有一个简洁的方法来做这个.我在最近几天堆积了这个问题.我看到很多应用程序中的那种segues转换,所以它似乎非常流行,简单的解决方案.我对Xcode只有几个月的经验不多.这是我的自定义segue(使用QuartzCore动画).
#import "CustomTabBarSegue.h"
@implementation CustomTabBarSegue
-(void)perform {
UIViewController *src = (UIViewController*)[self sourceViewController];
UIViewController *dst = (UIViewController*)[self destinationViewController];
UIView *currentView = src.view;
UIView *theWindow = [currentView superview];
UIView *newView = dst.view;
[theWindow addSubview:newView];
CATransition *transition = [CATransition animation];
transition.delegate = self;
transition.duration = 1;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromRight;
[[theWindow layer] addAnimation:transition forKey:@"MySegue"];
}
@end
Run Code Online (Sandbox Code Playgroud)
下面是来自destinationVC的我的按钮的代码.(不起作用)
- (IBAction)dismiss:(id)sender
Run Code Online (Sandbox Code Playgroud)
{
[self dismissViewControllerAnimated:YES completion:^() {
[self performSegueWithIdentifier:@"MySegue" sender:self];
}];
Run Code Online (Sandbox Code Playgroud)
}
我正在尝试使用自定义转换.我想从视图控制器1到2进行"覆盖垂直"转换,然后在移动到View Controller 3时再次将View Controller 2(中间的一个)向下滑动.故事板如下所示:
http://i.stack.imgur.com/bJYXI.png
我正在使用从这篇文章链接到的教程.并且还使用答案中提供的代码替换了.m代码:
Xcode自定义segue - 封面垂直对面(从上到下) - COMPLETE NEWBIE
我创建了一个UIViewController的子类,并将其命名为FromTopReplaceSegue.我的.h和.m代码如下所示:
.H
#import <UIKit/UIKit.h>
@interface FromTopReplaceSegue : UIViewController
@property(nonatomic, readonly) id sourceViewController;
@property(nonatomic, readonly) id destinationViewController;
@end
Run Code Online (Sandbox Code Playgroud)
.M
#import "FromTopReplaceSegue.h"
@interface FromTopReplaceSegue ()
@end
@implementation FromTopReplaceSegue
-(void)perform{
UIViewController *sourceViewController = (UIViewController *) self.sourceViewController;
UIViewController *destinationViewController = (UIViewController *) self.destinationViewController;
[sourceViewController.view addSubview:destinationViewController.view];
[destinationViewController.view setFrame:sourceViewController.view.window.frame];
[destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, -sourceViewController.view.frame.size.height)];
[destinationViewController.view setAlpha:1.0];
[UIView animateWithDuration:0.75
delay:0.0
options:UIViewAnimationOptionTransitionFlipFromTop
animations:^{
[destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, 0)];
[destinationViewController.view setAlpha:1.0];
}
completion:^(BOOL finished){
[destinationViewController.view removeFromSuperview];
[sourceViewController presentViewController:destinationViewController animated:NO completion:nil]; …Run Code Online (Sandbox Code Playgroud) 我的视图控制器中有一个按钮,我需要,一旦点击,将用户发送到下一个视图控制器,但它不起作用.我将ctrl从我的按钮拖动到我想要的控制器,连接是作为UIButton选择touchUpInside.我也命名了segue,但仍然没有.按钮本身甚至没有识别出触摸已经发生并且没有将我发送到任何地方.这是我的主视图控制器下面的一些代码:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
JDTHMainMenu *theMenu = [[JDTHMainMenu alloc] initWithFrame:self.view.bounds];
[self.view addSubview:theMenu];
}
- (IBAction)matchViewControllerButton:(UIButton *)sender
{
UIButton *matchScreenButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[matchScreenButton addTarget:self action:@selector(goToMatchView:sender:) forControlEvents:UIControlEventTouchDown];
[matchScreenButton setUserInteractionEnabled:YES];
NSLog(@"Open Match View");
}
- (void)goToMatchView:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"pushToMatchView"]) {
JDTHMatchScreen *vc2 = (JDTHMatchScreen *)segue.destinationViewController;
vc2.name = self.textField.text;
}
}
Run Code Online (Sandbox Code Playgroud)
我已将此视图控制器嵌入到navcontroller中,这是根控制器.我读到某个地方,也许我需要在我的appdelegate上添加一些东西,但没有什么是清楚的.我将发布任何更重要的代码,我仍处于学习的早期阶段,所以我不确定哪些内容是相关的.

模态控制器("模态")的"完成"按钮绑定到主控制器("主")中定义的退出操作:
@IBAction func done(segue:UIStoryboardSegue) {}
Run Code Online (Sandbox Code Playgroud)
"完成"按钮没有开火!
我在Xcode 6 Beta 4中尝试了Unwind Segue的手动segue方法,并将"完成"按钮动作绑定到"Modal"中的以下代码:
@IBAction func donePressed(sender: AnyObject) {
performSegueWithIdentifier("unwind", sender: self)
}
Run Code Online (Sandbox Code Playgroud)
它也不起作用!
如果我删除标签栏控制器一切正常 - 这是一个错误或限制?
PSThere是一个恼人的日志输出我无法摆脱:
2014-08-17 16:14:15.380 SwiftPhotoCards[9113:497540] 17545849:_UIScreenEdgePanRecognizerEdgeSettings.edgeRegionSize=13.000000
Run Code Online (Sandbox Code Playgroud)
不知道它是否与问题有关,但我认为值得一提.
在我的应用程序中,我有以下故事板片段:
从粉红色的按钮我添加了一个名为"toFishPic"的show segue到了更高的UIViewController.这是链接到粉红色按钮的快速代码:
@IBAction func toFishPhoto(sender: UIButton) {
dispatch_async(dispatch_get_main_queue()) {
self.performSegueWithIdentifier("toFishPic", sender: self)
}
}
Run Code Online (Sandbox Code Playgroud)
我不知道为什么,但是当点击粉红色按钮时,右侧的UIViewConroller(具有大UIImageView的那个)被加载两次,好像之后有一个相同.为什么会这样?
我已经使用本教程在我的ViewController中成功嵌入了一个UICollectionView内部UITableView.
下面可能会更有意义,如果你有一个快速浏览一下链接教程的代码(加上其学习过一记漂亮的东西!):
对我来说,下一步是从tableView UICollectionView内部的单元格执行segue UITableViewCell,但由于collectionView出口是在单独的View Controller中建立的,我不知道如何在主ViewController中引用它.
在TableViewCell.swift中有:
class TableViewCell: UITableViewCell {
@IBOutlet private weak var collectionView: UICollectionView!
}
extension TableViewCell {
func setCollectionViewDataSourceDelegate<D: protocol<UICollectionViewDataSource, UICollectionViewDelegate>>(dataSourceDelegate: D, forRow row: Int) {
collectionView.delegate = dataSourceDelegate
collectionView.dataSource = dataSourceDelegate
collectionView.tag = row
collectionView.reloadData()
}
}
Run Code Online (Sandbox Code Playgroud)
在ViewController.swift中,我需要能够,例如,在ViewController.swift文件中调用函数中的TableViewCell中的collectionViewprepareForSegue.我只需要用collectionView插座填补空白:
let destination = segue.destinationViewController as! SecondViewController
let indexPaths = self.___________.indexPathsForSelectedItems()
let indexPath = indexPaths![0] as NSIndexPath
let arrayObject = self.arrayObjects[indexPath.row]
destination.object = arrayObject
Run Code Online (Sandbox Code Playgroud)
'object'在SecondViewController中实现,如此var object: …
虽然我的TableViewController中只有一个像这样的单元格:
我用代码设置了多个单元格,并在单击时选择到不同的ViewController。
如何将我的TableViewController与多个ViewController连接,因为我将设置ViewController的Segue标识符。
提前致谢!
我想通过单击按钮进入CameraViewController,然后拍摄qr代码.我一直收到这个错误感谢U所有的帮助我给每个ViewController它在Storyboard中的类型
import UIKit
class movieListViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
@IBOutlet weak var movieTableView: UITableView!
var movie:[Movie] = [Movie]()
var currentMovies:[Movie] = [Movie]()
var counter = 0
override func viewDidLoad() {
super.viewDidLoad()
movie = Helpers.downloadJson()
self.movieTableView.reloadData()
sort()
}
func sort() {
movie.sort(by: { $0.releaseYear < $1.releaseYear })
movieTableView.reloadData()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return movie.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "MovieCell") as! MovieCell
cell.createCell(movie: movie[indexPath.row]) …Run Code Online (Sandbox Code Playgroud) segue ×10
ios ×7
swift ×5
uitableview ×3
objective-c ×2
storyboard ×2
action ×1
back-button ×1
ios5 ×1
iphone ×1
modal-dialog ×1
uibutton ×1
xcode ×1
xcode6 ×1