UIPopoverController做了个例子,在做时碰到一个郁闷的问题。例子代码检查没有问题,也不报错,可popover就是不显示,纠结哈。参考了些博文也没找到答案,最后无意中发现popover显示的位置我设的是向下UIPopoverArrowDirectionDown导致没能显示出来。
以下为实例:
// // SearchPopoverViewController.h // Ipad004 // 搜索框-显示popover // Created by Dwen on 12-11-2. // Copyright (c) 2012年 __MyCompanyName__. All rights reserved. // #import <UIKit/UIKit.h> @interface SearchPopoverViewController : UITableViewController @end
#import "SearchPopoverViewController.h"
@interface SearchPopoverViewController ()
@end
@implementation SearchPopoverViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 4;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = @"商品";
cell.detailTextLabel.text = @"约800条";
return cell;
}
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
@end
SearchPopoverViewController *spVC = [[SearchPopoverViewController alloc] initWithNibName:@"SearchPopoverViewController" bundle:nil];
// SearchPopoverViewController *spVC = [[SearchPopoverViewController alloc] initWithStyle:UITableViewStylePlain];
spVC.contentSizeForViewInPopover = CGSizeMake(200, 300);
popover = [[UIPopoverController alloc] initWithContentViewController:spVC];
[popover presentPopoverFromRect:[self.searchBar bounds] inView:self.searchBar permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
问题:
The problem: poor texture quality in android app written with Andengine(wraps opengl), especially on gradients which appear as steps in few colours. Problem occurs on real and virtual device
Settings: default texture, fullscreen, native resolution, android 2.2. I have tried to enforce PixelFromat with:
public void onAttachedToWindow() {
super.onAttachedToWindow();
Window window = getWindow();
window.setFormat(PixelFormat.RGBA_8888);
}
Haven't made any difference.
Commenting line: GLHelper.disableDither(pGL); helped a little with textures, but made particles look bad, so a guess it is not the source of problem.
Example loading code:
public static void loadResources(StreamgameActivity game) {
magnetTexture = new BitmapTextureAtlas(512, 512, TextureOptions.BILINEAR);
magnetTextureRegion = BitmapTextureAtlasTextureRegionFactory
.createFromAsset(magnetTexture, game,"bateria128CMatte_none.png", 0, 0);
game.getEngine().getTextureManager().loadTexture(magnetTexture);
}
解决方法:
方法一:
Andengine seems to use be default 16bit rendering mode. To change that I have done:
this.mRenderSurfaceView = new RenderSurfaceView(this); mRenderSurfaceView.setEGLConfigChooser(8,8,8,8,0,0);//!! mRenderSurfaceView.setRenderer(mEngine); mRenderSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888);//!!in onSetContentView method.
方法二:
if someone is experiencing poor texture quality and banding for GLES2 here is the solution: just overridepreDraw() of your Sprite and enable dithering like this:
Sprite electricityOff = new Sprite(0, 0, mElectricityOffTextureRegion, getVertexBufferObjectManager()) { @Override protected void preDraw(GLState pGLState, Camera pCamera) { super.preDraw(pGLState, pCamera); pGLState.enableDither(); } };Key element is pGLState.enableDither();. You will not need anything else but in case you want to ensure 32bit rendering for the surface and activity you can add:
@Override protected void onSetContentView() { mRenderSurfaceView = new RenderSurfaceView(this); mRenderSurfaceView.setEGLConfigChooser(8, 8, 8, 8, 24, 0); mRenderSurfaceView.setRenderer(mEngine, this); mRenderSurfaceView.getHolder().setFormat(PixelFormat.RGBA_8888); this.setContentView(mRenderSurfaceView, BaseGameActivity.createSurfaceViewLayoutParams()); } @Override public void onAttachedToWindow() { super.onAttachedToWindow(); Window window = getWindow(); window.setFormat(PixelFormat.RGBA_8888); }
eeeeeer 22