小编Kee*_*ano的帖子

片段翻转和损失图像

我已经完全重写了问题,以便缩小范围.

我有两个片段像卡片一样翻转(左,右).当前片段消失翻转时,它会显示背面.再次单击该按钮后,它再次翻转到前面,但前面片段上的ImageView消失了.

我尝试过保存所选图像数据的不同方法.

  1. 保存片段onSaveInstanceState

这给了我一个空指针,所以我想我创建后需要一些更恒定的东西.

  1. 所以现在我将图像保存到SDCard一次

这个我认为可行,只需检查路径并抓住它,如果它翻转到前面或重新创建活动.

这是一些代码

的onCreate():

@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.new_postcard_activity);
        //UI call
        frontImageView = (ImageView) findViewById(R.id.imageView);
        Log.d(tag, "onCreate() Instance:" + savedInstanceState);
        //fragment start
          if (savedInstanceState == null) {
              Log.d(tag,"Instance Null");
                getFragmentManager()
                        .beginTransaction()
                        .add(R.id.postcardFrame, new CardFrontFragment())
                        .commit();
                if(!mShowingBack){
                    Log.d(tag,"Not showing back");
                    if(newPath != null && newPath != ""){
                        Log.d(tag, "entered new path, not empty");
                        Drawable drawable = Drawable.createFromPath(newPath);
                        Log.d(tag, "Should be setting saved image.");
                        frontImageView.setImageDrawable(drawable);
                    }
                  }  
            } 
          else 
          {
                mShowingBack = (getFragmentManager().getBackStackEntryCount() > …
Run Code Online (Sandbox Code Playgroud)

android android-fragments

8
推荐指数
1
解决办法
1162
查看次数

数组到UITableView

这听起来很简单,从教程中看起来很容易.

我从他们的单词完全按照教程,仍然无法让我的UITableView上显示数组.

这是我的代码.

- (void)viewDidLoad
{
   [super viewDidLoad];
   // Do any additional setup after loading the view from its nib.
   salesArray = [[NSMutableArray alloc] init];

  //Add items
  [salesArray  addObject:@"Credit"];
  [salesArray  addObject:@"Debit"];
  [salesArray  addObject:@"EBT"];


  //Set the title
  self.navigationItem.title = @"Sale Type's";
}

-(NSInteger)tableView:(UITableView *)tableView 
                      numberOfRowsInSection:(NSInteger)section
{return [salesArray count];}

-(UITableViewCell *)tableView:(UITableView *)tableView 
        cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
  static NSString *CellIdentifier = @"Cell";
  UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  if(cell == nil)
  {
    cell = [[[UITableViewCell alloc]initWithFrame:CGRectZero 
    reuseIdentifier:CellIdentifier]autorelease];
  }
  NSString *value = [salesArray objectAtIndex:indexPath.row];
  cell.textLabel.text = …
Run Code Online (Sandbox Code Playgroud)

iphone objective-c ios4

4
推荐指数
1
解决办法
6102
查看次数

iCarousel未显示,方法未被处理

我试图通过两侧淡入淡出实现左侧iCarousel对象的权利.

所以我将GtiHub项目导入我的应用程序,为i​​Carousel分配了一个UIView ...将它链接到我的MainViewController上的IBOutLet并传递了Delegate以及DataSource,就像UITableViewController一样.

虽然它不会出现,我不确定可能导致这个问题的原因.

我的iCarousel DataSource是一个NSMutableArray*项目; 设计如下:

for (int i = 0; i < 100; i++)
{
    [_items addObject:@(i)];
}
Run Code Online (Sandbox Code Playgroud)

我正在ViewDidLoad中初始化iCarousel,如下所示

- (void)viewDidLoad
{
  [super viewDidLoad];
  //Initialize Carousel
  _carousel = [[iCarousel alloc] init];
  _carousel.delegate = self;
  _carousel.dataSource = self;

  //Carousel Testing Data
  for (int i = 0; i < 100; i++)
  {
     [_items addObject:@(i)];
  }

  //configure carousel
  _carousel.type = iCarouselTypeRotary;

}
Run Code Online (Sandbox Code Playgroud)

我的旋转木马代表方法如下:

#pragma mark -
#pragma mark iCarousel methods

- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
   //return the total number of items in …
Run Code Online (Sandbox Code Playgroud)

delegates objective-c uiview ios icarousel

4
推荐指数
1
解决办法
954
查看次数

AvPlayerLayer没有正确调整大小?

我有一个带UIImageView的旋转木马对象,我试图subLayer AvPlayerLayer.

尽管它没有填充_videoView的全部边界但它的高度更小,但是它已经测试了将高度更改为极值,并且只要它与UIImageView重叠,它仍然保持在那个大小.

我用来实现这个的代码如下:

    UIView *embeddedView = [[UIView alloc] initWithFrame:_videoView.bounds];
embeddedView.center = CGPointMake(100, 140);
AVPlayerItem *avPlayeritem = [[AVPlayerItem alloc] initWithURL:[NSURL URLWithString:[_videoURLS objectAtIndex:carousel.currentItemIndex]]];
AVPlayer *avPlayer = [[AVPlayer alloc] initWithPlayerItem:avPlayeritem];
AVPlayerLayer *avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:avPlayer];
[avPlayerLayer setFrame:embeddedView.frame];
avPlayerLayer.videoGravity = AVLayerVideoGravityResizeAspect;
[avPlayerLayer setNeedsLayout];
[embeddedView.layer addSublayer:avPlayerLayer];
[carousel.currentItemView addSubview:embeddedView];
//Assign to notication to check for end of playback
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didFinishPlaying:) name:AVPlayerItemDidPlayToEndTimeNotification object:avPlayeritem];
[avPlayer seekToTime:kCMTimeZero];
[avPlayer play];
Run Code Online (Sandbox Code Playgroud)

这是一个正在发生的事情的图像,因为你可以在顶部和底部分辨它: viewOffBounds

是什么造成这种情况,我该如何解决这个问题?

iphone uiview ios avplayer

2
推荐指数
1
解决办法
3122
查看次数

Angular 2服务未更新到组件

我正在进行Service调用以从MongoDB获取数据.这部分似乎正在工作,它在控制台中正确记录.

这个响应非常大,可能需要大约8秒才能完全进入数据.为此,我希望能够data[]在检索到数据后更新组件.

我目前的解决方案不起作用,我想知道实时检索这个的正确和最佳实践.即使响应时间稍长.

服务调用getData

export class DataService {
dataArray: any[];
constructor(private http: Http){}

//get all data
getData(): any {
    console.log('Api is calling getData...');
    this.http.get('http://localhost:8080/api/data').map((res: Response) => res.json()).subscribe((res: any) => {
        this.dataArray = res;
   console.log('JSON: ' + this.dataArray);
   return this.dataArray;
 });
}
}
Run Code Online (Sandbox Code Playgroud)

这正确地导入MainComponent,没有错误.

MainComponent

export class MainComponent implements OnInit{
data: Array<any>;
//Inject service here to use for getting data
constructor(private dataService: DataService){}

ngOnInit(){
    //Set View Data with Request from Server
    this.data = this.dataService.getData();
    console.log("Data: " + this.data);
} …
Run Code Online (Sandbox Code Playgroud)

rxjs angular2-services angular

1
推荐指数
1
解决办法
659
查看次数

B类NSArray返回NIL?

我只是试图在这两个类之间传递一个NSArray,每当我在B类中NSLog它的值时它返回NIL.

为什么这样,我如何让它显示到这个UITableView?

这是Class Ah

#import <UIKit/UIKit.h>
#import "Class B.h"

@class Class B;

@interface Class A : UIViewController  <UITableViewDataSource, UITableViewDelegate, UICollectionViewDataSource, UICollectionViewDelegate, UIPopoverControllerDelegate> {

    IBOutlet UITableView *ToolsTable;
    IBOutlet UICollectionView *strategyCollection;
    IBOutlet UIButton *countButton;
    IBOutlet UIButton *camerButton;
    IBOutlet UIButton *videoButton;
    IBOutlet UIButton *textButton;
    IBOutlet UIButton *probeButton;
    IBOutlet STPopOverQuestionViewViewController *questionListController;
    IBOutlet UIPopoverController *questionList;
    NSMutableDictionary *stratToolsDict;
    NSMutableArray *stratTools;
    NSMutableArray *stratObjects;
    NSMutableDictionary *QuestionDict;
    NSMutableArray *QuestionsList;
}

@property (strong, nonatomic) IBOutlet UIView *strategyOBJView;
@property (retain, nonatomic) NSMutableDictionary *stratToolsDict;
@property (retain, nonatomic) NSMutableArray *stratTools;
@property (retain, nonatomic) …
Run Code Online (Sandbox Code Playgroud)

nsmutablearray nsarray ipad

0
推荐指数
1
解决办法
64
查看次数